Proper coding and project organization (Part 1)

Posted by on August 21, 2007

I’ve seen lots of abominations regarding peoples code, but last day I almost got a stroke!

This guy was coding without any particular style, he was hard-coding any possible variable, performing the same calculations throughout the very same code and whatnot – A true code abomination!

Now, I understand that you might not be a pro and you’re doing this just for “fun” – But theres a line, my friend.

I won’t get tired of saying this: Your code should be an art form, not a kid’s drawing. (Don’t get me wrong, many kids in the world possibly draw better than I do, but that’s another story).

Let’s not talk about code optimization and let’s focus on the style and coding techniques for a moment, but first, let me tell you why this is so important:

Even if you like your coding, chances are that you won’t be able to understand what your code does if you a) save your files with any name, b) don’t keep a comprehensive file hierarchy and c) don’t comment your code.

The first 2 points are extremely important but so is the third one, despite all the knowledge you think you have, in 5 months when you see your code, you won’t get a clue of what it does, you’ll have to read the entire source from top to bottom and again just to understand what it was all about.

You can’t say it’s not your fault, when it is: Proper code documentation will save you time, despite your ideas of the opposite.

Code style:

Keep a steady way of coding, don’t define things as you go or use lot’s of global variables, use modular code instead – work in OOP if you want/like the idea and always keep things in separate modules, never put everything inside the same source – It makes for a bad reading, maintenance and might also difficult your debugging process.

By keeping things modular you gain both code independence and faster / easier ways of maintaining, sharing and/or documenting the code.

Comment it all:

Always add comments to those custom routines of yours, don’t let it be – and don’t say you’ll do it tomorrow, when you can do it right now.

Don’t be silly, it’s not a waste of time – To the contrary, you’ll be saving time and headaches.

The moment you pass the code to other’s hands or simply come back to it the next month, you’ll catch the flow instantly and focus on what’s important: coding.

Don’t waste your time, use it wisely – Plan beforehand, design, test. Keep things tidy and organized, you’ll love it.

Don’t code so it “works” – code so it “rocks”!

More to come later.

1 comment on Proper coding and project organization (Part 1)


  1. NielseN says:

    Seems quite fair to me. I wasn’t proficient on code style I kinda type as I go! as it turns out you have a point there. Looking forward for a second part!!

    One thing thats not clear is how should I create good documentation out of my sources?. It’s a nightmare please explain this!