| |

Freelancers: Generalize Your Code

One thing that was really driven home during my first year of grad school was the importance of reusable code. Not to say that it wasn’t taught to me as an undergrad, because it was; this year it just seemed to hit harder. As a freelancer in a niche market (small businesses, facebook apps), I tend to generate a lot of similar code. Just recently (within the last few months), I’ve started to generalize that code into reusable PHP objects, and it really helps.

I point out freelancers in the subject of this post because I feel, at least starting out, it’s not something freelance programmers (or designers for that matter) think to do. I know my concerns were more getting those jobs so I could code, not the process of coding. But whether it be a list of objects you can use on each site, or a HTML/CSS template with variables for the title, key words, headers, etc., you can save a lot of time in the long run by taking the extra time to abstract out the details and come up with something general you can use over a number of different sites. I, for example, have general code for: XHTML/CSS templates (NOT the design, just the general tags that should be applied to every site), [basic] contact forms, [basic] google maps, database objects, image uploading objects and XML parsing objects. Right now I am taking the time to look at other code I’ve done to see how I can generalize it.

This doesn’t only save time in writing the code either, but in testing. If you have core code that you know works, you don’t need to test for the general cases, or debug that code; just what you’ve added to customize it for that site or app. It’s stuff like this that will increase your productivity and your profits in the long run.

So generalizing code helps- and not just with time, but productivity and profits. And just about anything can be generalized to some extent. So the next time you code, take an extra moment to think how you can abstract away the details of that project (the variables if you will), and how much of what you are doing is reusable.

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *