KBD

Keith Devens .com

Saturday, May 17, 2008 Flag waving
And if you go too far up, abstraction-wise, you run out of oxygen. Sometimes smart thinkers just don't... – Joel Spolsky
← GZY: 'Gam Ze Yaavor/This Too Will Pass'Joseph Scott’s Blog » PHP::Interpreter →

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"?

← GZY: 'Gam Ze Yaavor/This Too Will Pass'Joseph Scott’s Blog » PHP::Interpreter →

Comments XML gif


Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

May 2008
SunMonTueWedThuFriSat
 123
45678910
11121314151617
18192021222324
25262728293031



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

new⇒Maps of Iraq

my husband is in Scania too..he​says it's not too bad..he's been at​worse...

Cristy: May 16, 3:54pm

"IMDB for music"

IMDB for Music? It looks to be a​couple of years old...​http://MusicTell.co...

Ken Empie: May 14, 9:57pm

Generated in about 0.28s.

(Used 8 db queries)