Yagni And Generality

People sometimes think that YAGNI means "don't do anything general, do everything specifically". This is not the case.

YAGNI says not to do anything general before you need it. Other rules, including XpSimplicityRules, say how to do things just as generally as necessarily and no more so.

When we do one thing, we do it clearly but simply. We probably see where it will need to be generalized, but we don't add the generality.

Soon, along comes another feature, where we could use some of the generality. So we do it one of two ways:

1. Sometimes we put the code in in a direct way, then generalize from viewing the two bits of code. This can help focus on doing just what it needed, and no more.

2. Sometimes we put in a little generality, then use it. This might save a small amount of time, but there is a risk of over-generalizing.

When another feature comes along, we again generalize and add it in. So the code is always as general as it needs to be to support what it actually does, but has no speculation in it.

See also EconomicsOfYagni


EditText of this page (last edited July 21, 2001) or FindPage with title or text search