Re: Booch's book feels too philosophical rather than practical?
- From: "topmind" <topmind@xxxxxxxxxxxxxxxx>
- Date: 25 Jan 2007 10:40:22 -0800
On Jan 25, 8:00 am, "Daniel T." <danie...@xxxxxxxxxxxxx> wrote:
"topmind" <topm...@xxxxxxxxxxxxxxxx> wrote:
On Jan 23, 5:30 pm, "Daniel T." <danie...@xxxxxxxxxxxxx> wrote:
Every time a new account type was added (a far more likely
scenario than changing the way current accounts work,) every case
statement would have to change. How many case statements are in
this code? From the chart, it looks like there would be 10 of
them. That's a lot of duplication in my book.
And visa versa with new operations to existing types.Yes, let's look at these two change scenarios and your example.(http://www.geocities.com/tablizer/bank.htm)
First adding a new plan: In a typical OO solution such a change will
require simply adding a new class. For your solution, adding a new plan
will require modifying 10 different switch statements.
I did not suggest using switch/case statements to model "plans". I
suggested a table(s). If the plans use existing features, then it is
only a table change.
Second, adding a new Feature where each plan implements the feature in a
different way: In an OO solution this would require adding a function to
6 different classes, while in your solution this will require adding a
single switch statement with all 6 implementations in it.
I am not sure what kind of p/r implimentation you are considering. I
evaluated multiple on that page to show different issues.
So, in the OO worst case, I need to add (not modify) 6 functions, in
your worst case, you need to modify 10 switch statements. Add to that
the fact that my worst case is less likely to come up than yours and OO
is clearly the better choice in your example.
This discussion reminds me of something I talked to my teenager about
the other day. I told her that when she is walking through a parking
lot, it is always better to walk behind cars even if it means going
somewhat out of your way. She asked why and I told her that it was
because if you walk in front of them you could get hit. She said that if
they are going in reverse and she walks behind them she could get hit as
well. But I reminded her (as I do you) that (a) cars tend to go slower
when in reverse and (b) cars go forward much more often than they go in
reverse. Take this as a metaphor for our conversation.
If frequency is the issue, I rarely have to modify parallel case/switch
statements in practice. I tend to model things as features, and let the
tables manage which things get which features. What you call "types"
are simply sets of features in my models. Often the programmer does not
have to be involved in assignment of which features go to which sets
because it is done through tables such that an app adminstrator can do
it thru a CRUD screen or an off-the-shelf table browser. The programmer
only has to get involved if a new feature is added. The programmer
controls the *existence* of the feature, but *not* the
taxonomy/classification/assignment of it to domain items. One uses
sets/tables to add such flexibility. DECOUPLE FEATURES FROM DOMAIN
TAXONOMIES/CLASSIFICATIONS.
OO'ers don't seem to get this, and hard-wire such into code out of
habit. There is a book called "Head First Design Patterns" by *four*
authors who claim to be OO experts, in which they *hardwire* Coffee
product taxonomies into the code. This is the crap being taught to our
young. In the future they will laugh at such crap, and OO will be
discredited by association (whether its OOs fault or not).
(Now I will agree that some p/r shops hard-wire stuff in code, but that
is not an inborn fault of p/r. They probably hired some cheap slophead
coder to get it up and running when they were small, and got stuck with
the design.)
-T-
.
- Follow-Ups:
- Re: Booch's book feels too philosophical rather than practical?
- From: Daniel T.
- Re: Booch's book feels too philosophical rather than practical?
- 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
- 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: 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: Daniel T.
- 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: Ecological software (was: Delta)
- 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):
Relevant Pages
|