Friday, May 02, 2008

Idle thoughts of a idle coder

Brian Tkatch has launched a thread on the PL/SQL forum about enhancements to SQL which would just basically save some typing: Things i wish SQL supported. The lazy man's list. This is quite a revealing thread, because it is always interesting to see what shortcuts people would like to take. It's a bit like peeking inside the medicine cabinet in other people's bathrooms (not that I would ever do that).

My personal wish is for:
select * {-empno} from emp;

That is, select all columns from the EMP table except EMPNO. This would be particularly useful for querying tables with BLOB columns in SQL*Plus.

As the thread as grown it has turned into a discussion of SQL theory ("conceptually, (using Venn diagrams) the tables/views are the circles, and the predicates define in what way the circles overlap") which requires too much concentration. The thread was supposed to be about laziness!

The patron saint of programmer laziness is Larry Wall, the inventor of Perl:
"The virtues extolled for Perl programmers are laziness, impatience, and hubris. Together, these admirable characteristics have led to the creation and use of many publicly accessible Perl modules. Because of laziness, programmers would rather write modules than repeat a procedure over and over (and would rather use modules written by other people than write new code from scratch). Because of impatience, programmers write consolidated code that is flexible enough to anticipate their future needs. And because of hubris, programmers share their triumphs with the rest of the Perl community and continually tweak their modules until they're the best they can be."


The problem with proactive laziness is that it can be hard to estimate how much effort will be saved later by putting in some extra effort now. Plus, writing automating utilities and code generators can just be a seductive form of procrastination. It feels like work but we aren't moving forwards. In the end we spend so much time sharpening the axe that we never get around to cutting down the tree. So the trick is to only automate the things we know it will be worth automating. This means doing something the plain way at first. Only when we get to the second or third cut'n'paste should we consider whether we need a parameterised module instead. The important thing is to automate early, in order to derive the maximum return on the work.

I am currently practicing cut'n'paste programming in a test data generator. I could refactor my code to drive off an array but re-editing my package to populate a collection will be a PITA. I should have done it some time ago, but I failed to realise just how many additional datasets I was going to need. At this point the ROI on the automation is quite small. So I have chosen to continue paying the find/copy/edit tax rather than spending half a day to figure out a better way of doing things. In the long run I will have expended more effort but in the meantime I keep making progress towards the main goal.

Update


Over on the Artima site Jeremy Meyer has written an article on Why it is better to be lazy.

Labels: , ,

5 Comments:

Anonymous CarlosAL said...

>>"That is, select all columns from the EMP table except EMPNO. This would be particularly useful for querying tables with BLOB columns in SQL*Plus."

And what happened to the good old views?

Cheers.

Carlos.

2 May 2008 at 10:31:00 GMT-7  
Blogger APC said...

>> And what happened to the good old views?

Yes I could build a view over every table which has BLOB columns just to support ad hoc (run by developer) queries in SQL*Plus. But where's the laziness in that?

Cheers, APC

7 May 2008 at 03:53:00 GMT-7  
Anonymous carlosal said...

>>"But where's the laziness in that?"

Aaahhh! I see the point now... ;)

Cheers.

Carlos.

8 May 2008 at 06:03:00 GMT-7  
Blogger Robert Vollman said...

What a great idea!

You know, you could write something that queries the user_tab_columns table and generates a query that selects only certain types of columns ...

12 May 2008 at 13:02:00 GMT-7  
Blogger Mberenis said...

This blog has been indexed by (R.T.S.S.E) Real-Time Statistical Search Engine internet technology. Leaving this comment posted on your blog will automatically send traffic from our search engine to your blog for free.

Try our Free Blogger Tool, and Blog by Statistics now!

TheRankDirectory.com

24 May 2008 at 21:21:00 GMT-7  

Post a Comment

<< Home