3 Places To Keep Your Pocket Code (Besides Your Pocket)Filed Under Code, Efficiency Tips
Every developer has some amount of code that they feel is reusable to them, but doesn’t clear that bar to be reusable for everyone.
This is what I call Pocket Code – reusable code that does not belong in reusable libraries that is shared amongst projects and team members, but code that you keep handy somewhere to be cut-and-pasted into applicable projects (I need not bring up the now famous State enumeration).
But where do we keep this code? Do we keep just lug it around on a memory stick or do we attempt to squeeze every last ounce of worth out of it? Here are some ideas besides keeping it squirreled away:
Code Snippet Websites
There are tons of code snippet sites and directories out there. Some are generic, while others are very specific to language or need. Here are the few that I use frequently:
- Code Project – http://www.codeproject.com/
- DZone.com Snippets – http://snippets.dzone.com/
- Regular Expression Library – http://regexlib.com/
- VS.NET IDE Snippet Library – http://gotcodesnippets.com/
- Joyent CodeSnippets – http://codesnippets.joyent.com/
Got another one we should look at? Feel free to add a comment below to your favorite snippet website.
Junk Drawer Assembly/Jar/Repository
This is the least favorite of all the possible choices; however, it is the one I most practice.
The first thing I do when starting a new project is to create the SVN repository. The second thing I do is immediately create a “toolbox” repository for that project that I call – the junk drawer.
Anything code that does not contribute to the product but does indirectly support it (quick and dirty data migration apps, record matching apps, or that crummy State enum) gets saved for prosperity in this repository. There is no structure or rules in the junk drawer.
I have seen people attempt to organically grow “reusable” libraries from these snippets in the forms of assemblies and jars. I highly frown upon this practice – you wouldn’t keep your yeast and flour in the same jar, why are you keeping junk and clean code together? Trust me, the maintenance headache of this practice far out weighs the ROI of ever reusing that pocket code.
The majority of developers who blog create posts only around code – making their code available for the entire world.
Here are a couple of thoughts on this:
- I love bloggers who post and explain code because it adds to community learning
- I loathe bloggers who post uncommented code with no explanation further than – “thought this might be useful to someone else”
- If you are blogging about something – normally you are passionate about the topic, so I will take that piece of code a little more seriously
Those are just some of my ideas, and I am sure there are a few others. Where do you keep your pocket code?