When to Generalize and When to Call YAGNI

https://globebids.com/media/items/1/1590/1590_orig.jpg

In Japanese there's an expression, "大は小を兼ねる” "The Greater Embraces the Lesser."  I find that it's a pattern that shows up repeatedly in software.  The general modeling of a problem will contain a particular instance of that problem.  A solution that solves the general problem will solve a particular instance of that that problem.

Like in Mathematics, solving the generalized form of a problem may be more complex.  Physics, the observable specific field of study helped inform the derivation of Calculus a generally useful concept across sciences.  Like the Russian Matryoshka doll, several layers of complexity may lie within a larger problem domain.  It's often tech's responsibility to suss out this relationship and pinpoint the layer that our business sponsors really want addressed.

For an engineer, it's frequently the case that addressing a particular instance will be faster and less complex to devise than the general purpose solution.  YAGNI (your aren't gonna need it) in fact encourages us to solve the immediate problem at hand rather than to attempt to foresee and solve the general problem without full information.  Sandi Metz's famous article on "The Wrong Abstraction," also does a great job of explaining this.

(大和証券 兼 大は小兼)

If we, including our business subject matter experts are inhibited by limited information we may not be able to pinpoint the specific problem nor its solution.  In such cases it's acceptable to address the larger problem than risk a pinpointed solution that misses the mark.  Also, if the specific problem is trivial or well understood and the general solution is at most marginally more expensive, it's justifiable.  It's in these circumstances that we say "The Greater embraces the Lesser."  Translated another way, "Better too general than too specific."

 

Comments

Popular posts from this blog

Engineering Truisms

The Telescoping Constructor (Anti-Pattern)

A Strategic Approach to Precision Process Automation