You are here
Home > Programming > Programmer’s Survival Tips – #4

Programmer’s Survival Tips – #4

Fallback Image

When writing code, the simplest solution to a problem is the best

Occam’s razor according to Wikipedia is “the principle that ‘entities must not be multiplied beyond necessity’ (entia non sunt multiplicanda praeter necessitatem). The popular interpretation of this principle is that the simplest explanation is usually the correct one. Simplest is not defined by the time or number of words it takes to express the theory; is really referring to the theory with the fewest new assumptions.” (See the article here)

So what William of Ockham probably didn’t know, was how true his principle would be for modern man, especially programmers. I have had to maintain many systems in my career as a programmer. I have maintained excellent works of pure genius that I have had the privilege to learn from, and I have had to unfortunately also maintain the worst unreadable spaghetti code imaginable. But every now and then, I come across a situation where the code has been totally over complicated.

Sometimes, programmers learn a new buzzword (LINQ, Lambda etc.) So without really understanding the concept, they try to make use of this ‘new’ technology or programming concept to perform a specific function in code that otherwise could have been done in a much simpler way. While I am not saying that you shouldn’t use new programming concepts, I am saying that you shouldn’t use them for the sake of using them and without knowing what you are doing. If in doubt between two approaches, you need to keep the following in mind:

  • How easy will it be to code
  • How long will it take me to code
  • Do I understand what I need to do
  • How easy will it be for others to maintain
  • How correct will my code be
  • Am I trying to ‘show off’ by using this code

Always be a humble programmer and never try to show off. Some of the absolutely best programmers I have come across have been the humblest of people. It’s usually the cowboys that get things wrong. Think of what kind of legacy you want to leave. Remember, your code (if it works) will remain for long after you are gone.

Dirk Strauss
Dirk is a Software Developer and Microsoft MVP from South Africa. He loves all things Technology and is slightly addicted to Twitter and Jimi Hendrix. Apart from writing code, he also enjoys writing human readable articles. "I love sharing knowledge and connecting with people from around the world. It's the diversity that makes life so beautiful." Dirk feels very strongly that pizza is simply not complete without Tabasco, that you can never have too much garlic, and that cooking the perfect steak is an art he has yet to master.

Similar Articles

  • Pingback: Tweets that mention Programmer’s Survival Tips – #4 -- Topsy.com()

  • Nicky

    I love your blog! I know nothing about computers or programming, but what you write is a great insight in to your world. Clear and simple writing! Keep the posts coming.

  • good points and the details are more precise than elsewhere, thanks.

    – Norman

    • Dirk Strauss

      Thanks Norman. Watch out for tip number 10 coming soon.

  • fenderbirds

    nice article, keep the posts coming

  • I’ll have to go back and read all your previous posts now.

Top