Keep Your Pocket Code
May 13th, 2008
Every developer, including me, 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.
For the reason not to keep just around with you on a memory stick here are some ideas besides keeping it more clever:
—
Development Websites
There are tons of code snippet sites and directories in the web. Some are generic, while others are very specific to language or need. Here are the few that I use frequently:
Please feel free to add a comment below to your favorite snippet website.
—
Repository
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 a toolbox of repository for that project.
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.
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?
—
Blogging
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.





