Re: Noun Oriented Thinking Considered Harmful
- From: "Kristofer Skaug" <nospam@xxxxxxxxx>
- Date: Wed, 2 Aug 2006 13:09:06 +0200
Nick Hodges (Borland/DevCo) wrote:
It does follow that the definition of the jumping belongs in some type
of class "TJumpingThing" from with TDog might descend, however.
Or better yet, IJumpingThing which TDog or one of its parent classes
implements.
I think that goes wrong, either way!
In a class-based approach, if we consider an (multiply) inheritable (but
extensible) behaviour then a "TJumpingThing" base class would have a virtual
"Jump" method with certain basic common (defining) characteristics. However,
unfortunately, whereas noun-oriented inheritance ("Is-A/Has-A" thinking)
somewhat guarantees a preservation of properties ('traits') from parent
class to descendants, with virtual methods (behaviour) this is not the case!
There is nothing in an OOP inheritance relationship that guarantees
similarity of behaviour between parent and child class, let alone specific
extended/overridden methods. Therefore, the notion of binding a "generic"
behaviour (function) to a class and asserting it would stay essentially the
same for all its descendants, does not hold up.
Using Interfaces, this situation is even more hopeless - since an Interface
enforces no functional promise whatsoever. If my class supports the
IJumpingThing interface, I could call its "Jump" method without the
slightest assurance that it won't start brewing coffee instead. The whole
point is that I shouldn't care, because that's the beauty of interfaces, the
implementing class knows best what it ought to do.
OOP goes wrong when it _forces_ you to model _everything_ in terms of
actors/objects.
Suppose you're just trying to create a function that bit-shifts a piece of
memory by N bits.
Who are the actors in this function? Is this an essential problem to be
solved? No!
The actor is "the program", or some (don't care which) subprocess or -thread
within it), which happens to need some bitshifting done on a chunk of data
(I don't care which data that is, either). I don't need a function that
looks like this:
class procedure TBitShiftProvider.Execute( Client:TBitstream; PlacesToShift:
integer);
In this case the designer has come up with a verbose answer
(TBitShiftProvider) to an irrelevant question.
A more to-the-point (and probably productive) question is, in this case:
What is this function supposed to do with the data? As soon as that has been
settled, one could be more than happy with a simpler (and - yay - globally
accessible) expression:
procedure ShiftBits( pData:pointer; DataSize,PlacesToShift:integer );
--
Kristofer
.
- Follow-Ups:
- Re: Noun Oriented Thinking Considered Harmful
- From: Anders Isaksson
- Re: Noun Oriented Thinking Considered Harmful
- References:
- Noun Oriented Thinking Considered Harmful
- From: Kristofer Skaug
- Re: Noun Oriented Thinking Considered Harmful
- From: Wayne Niddery [TeamB]
- Re: Noun Oriented Thinking Considered Harmful
- From: Kristofer Skaug
- Re: Noun Oriented Thinking Considered Harmful
- From: Nick Hodges (Borland/DevCo)
- Noun Oriented Thinking Considered Harmful
- Prev by Date: Re: Noun Oriented Thinking Considered Harmful
- Next by Date: Re: Noun Oriented Thinking Considered Harmful
- Previous by thread: Re: Noun Oriented Thinking Considered Harmful
- Next by thread: Re: Noun Oriented Thinking Considered Harmful
- Index(es):
Relevant Pages
|