Re: OOP/OOD Philosophy



On 6 Jul 2005 23:55:18 -0700, "frebe" <fredrik_bertilsson@xxxxxxxxxxx>
wrote:

>> if we are developing a system that must survive through years of
>> changing requirements, then coupling the GUI to the Schema is suicide;
>> and the time you might save in so doing is a false economy.
>
>Why would it be suicide to have a coupling between the GUI and database
>schema?

Consider the following pseudocode:

Item maxItem = new Item(0, "junk");
int totalAmt = 0;
foreach item in product {
print item.name;
print item.amount;
maxItem = max(maxItem,item);
totalAmt += item.amount;
}

The calculation of the 'maxItem', and 'totalAmt' are mixed in with the
printing of the the items. Other parts of the program eventually use
totalAmt and maxItem for other calculations.

Later, the folks who use the report decide that they don't want to see
the ZIGGY item printed on the report. This item is mostly just a
placeholder and just confuses the report. This is strictly a cosmetic
issue and should not affect any of the business rules.

A programmer makes the following change:

Item maxItem = new Item(0, "junk");
int totalAmt = 0;
foreach item in product{
if (item.name == "ZIGGY")
continue;
print item.name;
print item.amount;
maxItem = max(maxItem,item);
totalAmt += item.amount;
}

This fixes the report as required, but now the totalAmt and maxItem
variables are silently incorrect for any product that happens to
include a ZIGGY item.


-----
Robert C. Martin (Uncle Bob) | email: unclebob@xxxxxxxxxxxxxxxx
Object Mentor Inc. | blog: www.butunclebob.com
The Agile Transition Experts | web: www.objectmentor.com
800-338-6716


"The aim of science is not to open the door to infinite wisdom,
but to set a limit to infinite error."
-- Bertolt Brecht, Life of Galileo
.


Loading