How often you store code snippets, only to lose them again? Often enough (or maybe you aren’t writing that much code). There are plenty useful routines out there, already written, some you could probably rewrite in your sleep without looking them up and probably aren’t worth saving. Others are gems that need to be published for posterity- not for yourself, but more importantly for somebody else struggling with the problem/language for the first time.

So after much delay, besides posting snippets here in this blog, i’ve taken to posting some around. There’s also an interesting angle wrt copyright and code ownership which can be completely circumvented (thus ensuring the longevity of tried and trusted routines) if you publish your snippet in the public domain.

Strictly speaking, depending on the kind of labour contract you’re engaged in, whoever pays you, pays you for your time plus the product of your time, and by implication, with intent and legal claim to that code routine. A highly contentious topic if there ever was but a difficult one to implement or monitor.

Nonetheless, with certain freedoms in place, you can strike a happy balance between ensuring your client gets full copyright and ownership of code particular to their domain, while you remain free to reuse that general routine in another (unrelated or not) project with a clear conscience: public domain. Of course, again technically speaking, you need to decide who pays for the time on that routine, and it should be you unless there is a transparent agreement from your client. Yours to work out or not.

Other than that, just a general shout-out big THANK YOU to everyone who does post code snippets- it’s helped me huge in my career; hoping to pay it back to others somehow. And a general encouragement to everyone else… get pasting.