KBD

Keith Devens .com

Wednesday, July 9, 2008 Flag waving
Your best? Losers always whine about their best. Winners go home and fuck the prom queen. – John Mason (The Rock)

Archive: August 20, 2005

← August 19, 2005August 23, 2005 →

Daily link icon Saturday, August 20, 2005

Stroustrup is with me on premature abstraction

Stroustrup is decisively with me on premature abstraction:

Bjarne Stroustrup: ... I think I have a tendency to build the specific case first if I haven't tried something several times before, because it is pretty fundamental that we understand the concrete solution better than the abstract. When I see the same problem again and I get half way into the solution, I say, "Wait a minute, I'm doing the same thing twice." I did it once. I sort of understand it. I know what I mistakes I made in the previous solution. Now is the time to step back and see if I can have a general solution. That approach contrasts with the approach taken by people who start generalizing before they've tried it once—they sit trying to design a general solution to a problem that they have no experience with.

Bill Venners: That sounds like premature generalization.

Bjarne Stroustrup: Yes, that's right. You can have premature generalization as well as premature optimization.

(emphasis mine). Ray Davis of UC Berkeley makes similar points (last emphasis mine):

Lazy optimization is already a familiar idea: Don't waste time trying to guess at how to make lower-level code more efficient. Think about it during the high-level design and then gather evidence to show where performance and scalability need work.

Lazy generalization doesn't get talked about as much. But just as good programmers have an urge to make code clean and efficient, they also have an urge to generalize and make code re-usable. Much of the time they do that prematurely, get attached to their beautiful premature generalization, and the project drags. Instead, we try to wait for evidence that it's needed – usually the first copy-and-paste.

Incidentally, which name do you like better... "premature generalization" or "premature abstraction"?

  1. GZY: 'Gam Ze Yaavor/This Too Will Pass', via.

       (0)
  2. Slava Pestov : Some reasons why image-based languages are better.

       (0) Tags: [Programming]
  3. Slava Pestov : Very common mistake: try/finally with two streams:

    Isn't boilerplate code great? ... I'd rather use a language with higher-order functions encapsulating resource usage idioms...

       (0) Tags: [Programming]
← August 19, 2005August 23, 2005 →
July 2008
SunMonTueWedThuFriSat
 12345
6789101112
13141516171819
20212223242526
2728293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 2 posts

Recent comments XML

getElementsByClass function

http://pitfalls.wordpress.com/2008/​07/07/querying-it-jquery-way-getele​ments...

maxgandalf: Jul 7, 5:50am

Generated in about 0.047s.

(Used 7 db queries)

mobile phone