Extracting an Open-Source Library From An Existing Codebase
slides.com/sophiedeziel
Hello! I'm Sophie!
I am a software developer @ Acquisio, a Web.com company
I organize Ruby meetups
I love snowboarding, GIFs and my rabbits
@sophiedeziel
So you got that big pile of useful code
Benefits of extracting open-source code
- Will simplify your actual codebase
- Can bring collaborators to add features and fix bugs
- Fresh and new ideas
- Useful code for your future (or parallel) projects
Ideal for a first Open-Source project!
Where to find useful code to extract?
About anywhere!
Are you solving common problems?
Have some cool scripts?
This talk is a step by step guide to extract a library from existing code
Step 1:
Identify what you want to open-source
Problem solved
scope
interface
Step 2:
Refactor your code to move as much as possible in well defined classes/modules
Decouple
Test
Break dependencies
expose interfaces
Step 3:
Setup of the library
Package manager
Create a new folder for your project and follow the instructions specific to your ecosystem.
Android Studio tutorial:
goo.gl/XRtkef
Checklist:
- Boilerplate code
- Test framework
- Version Management System
- Package repository accounts
Step 4:
Move the code!
Pro tip: Move the tests first
- Make sure all dev and test dependencies are set up
- Some minor changes to the test setup are expected
- Make sure they run
- Make sure they fail properly
Move the implementation
One by one, make those tests pass and repeat!
Refactor
Add features
Refactor again
Step 5:
Try it locally
Configure your codebase
- Integrations test
- Follow your ecosystem's way of packaging the library
- Add it as a dependency to your application
- Make the tests pass!
Step 6:
Publish!
Licence
choosealicense.com
Code of conduct
contributor-covenant.org
Version number
I recommend following Semantic Versioning
MAJOR . MINOR . PATCH
Pro tip: Use and abuse Git/Github features
- Readme for documentation
- Push hooks to test
- Issue tracker
- Projects
- Tags for releases
- Branches to merge and release bugfixes across versions
Distribute!
Make sure it is:
- Compiling
- Passing tests suite
- Documented
Then upload it to (a|many) library repository!
Step 6:
Profit.
Step 6:
Maintenance
Bugs
New features
Pull requests
Never forget about the documentation
Open-Source Essentials
- CI servers are good friends
- Contributing guides are also your friends
- Set expectations on PR (fully tested, code style)
- Use automated review tools (CodeClimate, Hound)
- Build a team you trust
Don't burn out
- Those pull-requests can wait
- Those bugs can wait
- Delegate! Delegate!
- Your free time is YOURS
- You don't owe anyone anything
Enjoy it
Step 7:
Profit!
Thank you!
All background pictures from unsplash.com
slides.com/sophiedeziel
Extracting an Open-Source Library From An Existing Codebase
By Sophie Déziel
Extracting an Open-Source Library From An Existing Codebase
Talk prepared for the GDG DevFest 2017, Montreal.
- 1,343