Re: Booch's book feels too philosophical rather than practical?
- From: Robert Martin <unclebob@xxxxxxxxxxxxxxxx>
- Date: Tue, 23 Jan 2007 18:57:47 -0600
On 2007-01-23 15:02:42 -0600, "topmind" <topmind@xxxxxxxxxxxxxxxx> said:
Robert Martin wrote:Procedural programming allows you to add new functions without changing
the existing data structures. OO allows you to add new data structures
without changing the existing functions. You need both capabilities.
You mean adding functions and "subtypes" without changing existing
code?
Sometimes you have functions that can deal with many different kinds of data structures. Often these functions will have a switch/case statement in them for the parts of those data structures that vary. You can add new functions any time you like, without having to make any changes to the data structures.
OO gives you the opposite ability. Sometimes you have functions that deal with with a particular kind of data structure. Often these data structures have variants. If you treat them as OO subclasses then you can add new variant data structures any time you like without having to make any changes to the existing functions.
There are table-driven ways to do such and even file-driven ways.
Of course. OO just hides these techniques behind a language syntax.
I don't find a
practical need for such very often in biz apps, though.
I have seen you make that startling statement many times. I make use of this ability of OO all the time in business applications. Perhaps we just have very different world views.
But you forgot to mention another change pattern: loss of mutual
exclusiveness. If 2+ options change to no longer be mutually exclusive,
then procedural fairs better. It is a smaller change: just change the
CASE to IF statements. With polymorphism you have to move code to
different named modules, and I give that a much higher change cost
score.
On the contrary the the change in an OO program is remarkably simple. One simply puts the objects that represent the non-exclusive options into a composite.
--
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 |
.
- Follow-Ups:
- References:
- Booch's book feels too philosophical rather than practical?
- From: arnuld
- Re: Booch's book feels too philosophical rather than practical?
- From: Daniel T.
- Re: Booch's book feels too philosophical rather than practical?
- From: topmind
- Re: Booch's book feels too philosophical rather than practical?
- From: Robert Martin
- Re: Booch's book feels too philosophical rather than practical?
- From: topmind
- Booch's book feels too philosophical rather than practical?
- Prev by Date: Re: Simples Rules make creating Big Balls of Mud impossible.
- Next by Date: Re: Booch's book feels too philosophical rather than practical?
- Previous by thread: Re: Booch's book feels too philosophical rather than practical?
- Next by thread: Re: Booch's book feels too philosophical rather than practical?
- Index(es):