Monday, December 24, 2012

Only one line of code needed

The above statement is pretty profound if you think about it.  Can a program run with just one line?  Why would you write a program with just one line?

You really cannot write a fully functional program with one line.  The abstract principle here is the fact you have to think about not only get the job done but writing it in a few lines as possible.  Long ago when COBOL was king, programmers where suppose write 10 lines of debugged code per day.  Although that standard was so little because it took hundreds of lines to get anything accomplished and most COBOL programmers could write hundreds of lines per day.

The principal behind a single line of code is simple.  You have only one point of failure.  But realistically if you write 100 lines of code that can easily be debugged and your coding partner can write the code in 10 lines, whose is better.  If those 10 lines of code are easily debugged, then the winner is your coding partner.  You on the other hand will be working harder and longer for the rest of your coding life.

Windows XP had about 45 million lines of code.  Windows 7 has around 80 million lines of code.  It has been said that Linux Kernel has grown from 10,000 lines when it first came out to around 15,000,000 lines. Each line that gets added while none of lines are removed is good for employment but not so good for the employer that is trying to compete with the new OS or application program that is smaller and functionally better.

What this shows is that as you add more functionality to your code it grows and becomes this monster that not a single person can maintain any more.  So the goal is to add enhancements and bug fixes without impacting the total number of lines exponentially.   Can I make this change if think about in 40 lines of code instead of 300?  That is the important question that must be answered every time a line of code is needed.