Clean Codebase

From WCell

Jump to: navigation, search

A clean codebase (also refered to as "high quality of code") is the sole most important factor when it comes to figuring out the value of a project, written in any computer programming language.
This article should explain why the WCell-team emphasizes Quality Control so much.


Contents

[edit] The choice of the language

The language being used and its complexity determines the degree of difficulty to maintain code.
Generally can be said: More comfortable languages improve development-time but slow down runtime performance.

See also: Why C#?

[edit] The promises of a clean codebase

  • Re-usability: The ability to re-use code instead of copy&pasting - which again is one of the clean codebase' worst enemy
  • Easy bug-finding and -fixing (don't think your code won't have any, they always sneak their way in!)
  • Code is more overviewable, more comprehensive and more self-explanatory
  • A new developer is able to easily understand the existing code-structure and is also able to make assumptions about unknown code which again enables him/her to write code without having to look through a lot of foreign code just to ensure that his/her assumptions are true.
  • The ability to perform major changes with the smallest possible effort, through: Encapsulation
    • This also enables us to easily apply changes that are required to increase performance
    • By clearly seperating different systems and their functionality, simple changes or fixes for one system will not affect (and eventually break) other parts of the application

[edit] Don't missunderstand it

A common miss-assumption is that a clean codebase would be more resource-intensive - But that is just not the case.
A lot of developers would rather access certain fields directly or copy&paste a whole lot of functionality to keep calling of methods/functions to a minimum, and it is true: A few jumps less might result into slightly faster execution of the code, but it also becomes less overviewable and we thus lose the ability to figure out leaks and ensure a steady code-flow. In addition, trying to apply changes to that kind of code always prooves to be quite a pain.
We refer to performance gained through this technique as an invisible performance gain, because: No one will notice it.

[edit] The most important and most expensive resources

Everyone (also hobby developers) should always have these in mind:

  • Labor
    • If you work with bad code, you will have to invest more time to figure out how it works, more time to fix stuff and even more time to figure out why your fixes don't work
    • Your boss doesn't pay you to give him garbage that no one else can really use or that has to be redone after a couple of years
    • When working on a project you are investing labor - no matter if paid or not. Did you ever count the hours that you invested into your little hobby project and calculated how much money you could have gotten for that if you would have spent that time on a paid job?
  • Time
    • When the time runs short, you want to be sure that what you produced so far is not going to give you more of a headache than you already have
    • Working under pressure will always lead to quick&dirty fixes. Don't go down to that level before really necessary
  • Reputation of the company or organization
    • Bad code means more bugs: People who use your program complain and the company or organization gains a bad reputation - simple as that
  • Developers' Motivation to work with the code (you cannot even buy this)
    • After working on something for several months in a row, you should still be motivated to work on it and not just bang your head against the wall because you produced the worst mess that is no fun to work with anymore
    • No decent developer really wants to touch butt-ugly code - Your project won't make it for too long if you don't have a sound codebase
    • Are we all conformers? Yes! Because this is what makes us happy: Working with something that we are used to and can easily familiarize ourselves with - Not something that is prone to end up in the garbage or be forgotten once the creators do not invest anymore time into it.

[edit] How do I achieve a clean codebase

Start by following our Coding Guide

Personal tools