01.Blogs :
RobMiles  
Programming, gadgets and life as a lecturer in a UK university.

We Need More Lazy Programmers

I've been putting some bits and bobs into the C Sharp Wiki that we have going at Hull. 

This is my take on Creatve Laziness:

This is lazy in a good way. It means that rather than solve a problem I'll tend to build a machine to solve it, and then use the machine. It is this kind of thought process that got us to invent lawn mowers rather than spend all our time hacking at the grass with big knives.

As an example, if you wanted to get from a user an age value between 5 years and 100 years you could write some C# to do that. However, it would be more sensible to write something which would read a value and ensure that it is within a particular range. Then, when you need to read in a speed value between 0 and 70 you can use the same code to do it.

This is called generalising, where you make a more general solution than the specific problem requires, on the basis that you may be called to handle similar cases later. Of course you have to make sure that you don't use too much effort performing the generalisation, rather than repeating the task

This approach pays off in other ways as well. If you only write the code in one place; should you find a bug in the code or need a change in behaviour you only have to update it once.

So, form the habit of stepping back from what you are trying to do, and consider what you are really trying to do. Solve the slightly bigger problem. And never have to solve anything like it again.

posted on Friday, October 15, 2004 9:52 PM by RobMiles

# @ Friday, October 15, 2004 9:57 PM

I totally agree with everything you're saying there... the one thing you didn't mention though, is that generalization in the form you are talking about is probably one of the most difficult things to do *right*. (with right being the key there).

AdamMB

# @ Saturday, October 16, 2004 12:01 PM

I agree too, I always try to incorporate everything which Rob has said in lectures or elsewhere about programming practices and techniques, and the quality if my code has gone up no end. There have been many times when I've saved myself hours of time by taking the time to do things sometimes a slightly harder way to start with :)

Pandilex

# @ Saturday, October 16, 2004 3:49 PM

While I have been called lazy on occasion I like to think of myself as efficient. That’s my story and I’m sticking to it.

AlfredTwo

# @ Sunday, October 17, 2004 8:09 AM

I reckon this concept of Rob's as being a creatively lazy is something which can help this world to change into world of inventors. I am tending to love this concept now and try to follow this while i am writing a code or even doing some other work... " The concept is really great..."

agurha


 
03.UPDATE CALENDAR :
<October 2004>
SunMonTueWedThuFriSat
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

05.MY LINKS :

07.Subscriptions :

Subscriptions


© Copyright 2005 Microsoft Corporation. All Rights Reserved.
Terms of Use | Privacy Statement | Code of Conduct | Hosted by MaximumASP for Microsoft
WHO-BAR