Top-Down Design: Garmin GPS Software
Top-Down Design: Garmin GPS Software
Track
Track
Point
Point List
Object
Refine the design at each step
Decomposition / Divide and Conquer
Not a perfect, pretty picture
Boxes at lower levels are more concrete
and contain things like GPS records, actual
strings
Boxes at higher levels are more abstract
and closer to dealing with the user
In between are worker bees that do things
like file storage and waking up Google Earth
But dont take the hierarchy too seriously
Most things dont fit perfectly into trees
Bottom-Up Design
Just the opposite: start with parts
User
Interface
Show Export to Find
Compare
Ridec Google Similar
Track
Track
Point
Point List
Object
Composition
Build-It-Yourself (e.g. IKEA furniture)
Top-Down vs. Bottom-Up
Is one of these ways better? Not really!
Its
sometimes good to alternate
By coming to a problem from multiple angles
you might notice something you had previously
overlooked
Not the only ways to go about it
Waterfall
Better:
public int absProduct(int a, int b) {
return a*b > 0 ? a*b : -a*b;
}
... ...
public double length() { public double length() {
return _length; return _p1.distance(_p2);
} }
} }
Can you see how this code could evolve
later and accidentally become inconsistent?
Duplication may be desirable for
performance, but dont optimize too soon
DRY Principle
Dont Repeat Yourself
after
if (isSummer(date)) {
charge = summerCharge(quantity);
}
else {
charge = winterCharge(quantity);
}
Refactoring & Tests
Eclipse supports various refactorings