Principles of Programming

Photo Credit:

The following 3 principles are used in any sort of web development, and exemplify the strange colloquialisms of programmers. Entire books are written on how to follow each of these so I will try to be brief and hit the gist of how to apply them.

DRY (Don’t Repeat Yourself)
When writing code you should not copy and paste a logical section of code in multiple places, when doing so you increase the likelihood that when you update it in the future you will have many areas that you would have to touch to make that change. This can cause all sorts of bugs. The best way to approach this is to use reusable functions that are located in one spot, allowing any future changes to be done in that one area.

KISS (Keep It Simple Stupid)
When writing code, if you can do it in 1 line why write 50? Seems obvious and when said in this fashion you can’t avoid the logic. However in practice, programmers tend to write code and try to extend it to do everything that they can think of, while there isn’t anything wrong with this line of reasoning, unless you have a specific goal, its overkill.

YAGNI (You Ain’t Gonna Need It)
This is similar to KISS, why write whole sections of code that won’t be used within a program, even if those sections online have one line and follow the KISS principle. Sometimes items are written into the code that are simply not going to be used in your particular project. If at all possible you should avoid this and either not write it or remove it from the project.

I personally try my best to adhere to these principles and have found over the years that anytime I stray from the path I end up regretting it at a later date. While these are aimed at coding perhaps you can find a use for them in your job, or maybe you have some principles that you try and follow. If so what are they?

Here is a great article from NetTuts that explains it in much more detail:

Tags: , ,
This guy can program a website to do jumping jacks.

Leave a Reply

two + = 10