The Root of All Evil is ...

Ovid on 2005-10-03T22:58:47

Many people cite the famous quote "Premature optimization root of all evil", but that's just a specific case of a more general problem: trying to fix things that aren't identified as a problem. YAGNI is God.


But what's a "problem"?

Adrian on 2005-10-04T08:47:26

Many people cite the famous quote "Premature optimization root of all evil", but that's just a specific case of a more general problem: trying to fix things that aren't identified as a problem. YAGNI is God.

I, of course, agree completely :-)

However it can be tricky to pull off if different people have different ideas of what a "problem" is. To me, duplicate and/or unclear code is a big problem. Something that needs fixing straight away. Other people don't seem to think that way unfortunately.

Re:But what's a "problem"?

drhyde on 2005-10-04T10:12:29

I'm of the opinion that premature generalisation of code is just as evil as premature optimisation. So many people want to write all-things-to-all-men generic frameworks when all their customer has asked for is Hello World.

Re:But what's a "problem"?

Adrian on 2005-10-04T10:30:24

I agree completely that premature generalisation that creates the kind of uber-frameworks that many Java folk seem enamoured off is evil.

That's not my aim however. I'm removing duplication. I'm solving an existing problem with less code. I am very definitely not trying to solve any general problem that isn't in the code already.

Re:But what's a "problem"?

drhyde on 2005-10-04T11:59:27

I wasn't talking about you - or indeed about anyone in particular. The thread just prompted me to repeat something I was ranting about in the pub last night.

Re:But what's a "problem"?

Adrian on 2005-10-04T12:15:20

In that case rant away :-)

Re:

Aristotle on 2005-10-15T16:27:54

Architecture astronauts?

The problem of course...

Alias on 2005-10-04T12:22:17

The problem of course, is that YAGNI also stands for You Are Gunna Need It, and it's often bloody difficult to tell which one it is.

I have this happen regularly. I admit I tend to be a bit "visionary" and see further ahead than many, and as a result a lot of my first implementations tend to be very general. They used to often be overly general, although I've tried to retrain myself a bit more lately.

The problem of course is that when you think you Ain't gunna need something that will be hard to change to using later once you establish standards for things.

You really Are going to need them, but you just don't realise it yet, when someone else in the project is working or thinking a bit further ahead.

There's also the whole issue of flexibility versus generalisation. The former is almost always good, the latter can often be bad. There are often small and cheap things you can do to make your code more flexible, so it can be used in ways you don't expect, without adding much bulk at all.

Re:

Aristotle on 2005-10-15T16:34:30

I haven’t had any luck trying to track this down, but Knuth is said to have something along the lines that each problem in software can be solved with either more or less abstraction, and that experience tells us which one is the way to go.

(If someone has a citation, I’d love to know it.)

My corrollary

petdance on 2005-10-04T14:20:35

My take is that any code that's written that doesn't need to be written, including any generalization, is by definition premature.