Re: Noun Oriented Thinking Considered Harmful



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


.



Relevant Pages

  • Re: A Java "interface" declaration does not allow a constructor to be specified in it ...
    ... and thus inherits the method transport from both ... The child class is the one causing the name conflict. ... the conflicting methods in one of the parent classes. ... multiple interfaces with the same method signature can ...
    (comp.lang.java.programmer)
  • Re: Second class coding :(
    ... They all use the same input and output var types and override the ... defined in the parent in an overridden create constructor. ... I 'use' the parent class and dynamically load the ... descendants with their differring values and access that function with it's ...
    (alt.comp.lang.borland-delphi)
  • Re: VB language extensions wishlist
    ... As mentioned elsewhere in this thread, its ability to have child classes inherit their parents' methods is next-to-useless for me, as you end up writing about three times the code you would in full-inheritance languages. ... In the Collection example given, ArrayedCollection and LinkedListCollection probably all have a Remove method, and if I don't override that, it should automatically use the Remove method from the parent Collection class as though it had been written in each child class. ... Classes and interfaces are two very different thing in OOD. ... I have apparently been doing the impossible, because I have created quite a few interfaces in VB6. ...
    (microsoft.public.vb.general.discussion)
  • Re: activex as ui for com
    ... >>interfaces only. ... >> But this is a little different situation, parent application host the COM ... >> using ineterfaces, activex would need to instatiate that COM also tou use ... > to the ActiveX control. ...
    (microsoft.public.vc.atl)
  • Re: activex as ui for com
    ... >interfaces only. ... > But this is a little different situation, parent application host the COM ... > using ineterfaces, activex would need to instatiate that COM also tou use ... to the ActiveX control. ...
    (microsoft.public.vc.atl)