Вы находитесь на странице: 1из 1

Simplicity is the Key

A simple design always takes less time to understand the "only once" part but not the
to finish than a complex one. So always do "once and" part. The first part means express
the simplest thing that could possibly work all the intention of your code even if it means
next. If you find something that is complex duplication.
replace it with something simple. It's always Consider a simple example; you
faster and cheaper to replace complex code multiply by 100 to turn a fraction into
now, before you waste a lot more time on it. percentage and you also multiply by 100 to
Many people try to measure simplicity. turn meters into centimeters. Should you have
Simple defies measurement because it is a a single function that multiplies by 100 called
very subjective quality. One person's simple is convertToPercentOrMeters(x)? NO! Not even if
another person's complex. Adding an it would remove some duplication. You want
advanced technology can simplify one two methods; converToPercent(aFraction), and
application and make a complete mess of convertMetersToCentimeters(aLength) . You want
another. two because they tell you different things. Not
Within your project the team decides just that you will multiply by 100 but also
what is simple. Together you judge your code why you will multiply by 100 and what kinds
subjectively. I recommend four subjective of numbers are valid inputs.
qualities; Testable, Understandable, One thing about simple designs is that
Browsable, and Explainable (TUBE). they require knowledge to recognize.
Testable means you can write unit tests Knowledge is different from information, you
and acceptance tests to automatically check can have plenty of information and no
for problems. This impacts the overall design knowledge. Knowledge is insight into your
and coupling of objects in your application. problem domain that develops over time.
Break your system into small testable units. Simple designs often come after the
Browsable is the quality of being able project has been running for a while. The best
to find what you want when you want it. approach is to create code only for the
Good names helps you find things. Using features you are implementing while you
polymorphism, delegation, and inheritance search for enough knowledge to reveal the
correctly helps you find things when you need simplest design. Then refactor incrementally
to. to implement your new understanding and
Understandable is obvious, but highly design.
subjective. A team that has been working Keep things as simple as possible as
with a system a long time will understand it long as possible by never adding functionality
even though someone new is completely before it is scheduled. Beware though,
baffled. So I also recommend explainable as a keeping a design simple is hard work.
quality that means it's easy to show new
people how everything works.
Many people recommend a measure of
simplicity as: Once and only once. It is
important to remember this has two parts.
Everyone seems

ExtremeProgramming.org home | XP Rules | System Metaphor | About the Author


Copyright 1999, 2009 Don Wells all rights reserved. TUBE mnemonic created by Zachary Spencer.

Вам также может понравиться