A Good Programmer is a Lazy Programmer

The Art of Being Good and Lazy

By Dan Nations, published Dec 04, 2007
Published Content: 5  Total Views: 823  Favorited By: 0 CPs
Embed:  
Rating: 3.5 of 5
One of my favorite sayings is that a good programmer is a lazy programmer.

I know what some of you are asking: How can a lazy programmer be a good programmer? Note, though, that I didn't say a lazy programmer was a good programmer, but that a good programmer was a lazy programmer. There is a distinct difference!

The Art of Being Good and Lazy

One of the most basic rules of programming is that repetitive code should be put into a function (or a subroutine, or a class, etc.). If you were to write a piece of code that required several strings to be capitalized you would not write the logic to replace lower case with upper case for each instance of that string; you would write a function that accepted a string and returned the same string in all caps.

This is something that every programmer knows.

But, the basic idea is something that should always be on a programmers mind. Most sets of code that is repeated throughout a program, or throughout many programs, and follows a pattern can be done better by using functions or classes.

It is a fundamental rule of a good programmer, and yet it is something that many programmers don't follow. Don't get me wrong -- most developers understand and utilize the concept on a micro scale -- but the concept is not limited to micro-use. It can be used for almost any set of code, big or small, and in almost every programming language.

Take, for example, your standard data entry screen. When I developed in Visual Basic using a SQL Server to store the data we did not use dataset objects on the form. Instead, we used "unbound" forms where we would write the functions to put data onto the form or save data from the form to the database. This is good programming because it reduces the hit on both the client and the server.

But, it requires huge chunks of code to be written for each form. The fetch code would open a recordset, populate it, individually place each value form the recordset to the form, and then close the recordset. The save code would do the same thing in reverse.

Comments
Type in Your Comments Below - (1000 characters left)
Your name:

Submit your own content on this or any topic. Get started »
Most Commented On