Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^2: Possibly Stupid OOP question (order)

by tye (Sage)
on Feb 27, 2008 at 03:24 UTC ( #670467=note: print w/replies, xml ) Need Help??

in reply to Re: Possibly Stupid OOP question
in thread Possibly Stupid OOP question

It also helps to put the classes higher in the source file than the uses of them (which matches how classes get used when in separate files). The good practices that you described are also ways to overcome not using this "natural order" but it can still be a good idea to stick to the usual order.

I'll also note that the original code smells like a typical design made after reading a typical introduction to OO programming. Jumping to using inheritance is probably the most common mistake made by OO programmers who haven't yet become old and tired. Old, tired OO programmers have learned that an "is a" relationship is very tight and quite inflexible and so should be reserved for rather rare cases and only used for a very fundamental connection (and that fundamental connections can still usually be better implemented without inheritance).

- tye        

  • Comment on Re^2: Possibly Stupid OOP question (order)

Replies are listed 'Best First'.
Re^3: Possibly Stupid OOP question (order)
by jepri (Parson) on Feb 27, 2008 at 06:12 UTC
    It is funny that most OO books bang on about inheritance so much when the guy who invented the term OO thinks that OO is:

    "OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things." -- Alan Kay

    Bots of the disorder.

      I think this is such a common pitfall, at least in part, because a person writing a tutorial about OO needs to mention and explain inheritance and so also feels compelled to explain the "power" and "benefits" of inheritance. The pitfall is going on and on about the benefits, rarely even mentioning the pitfalls, and using really sucky examples to explain all of the things that can be done with inheritance.

      Though I'm often quite disappointed that tutorials on OO nearly fail to mention data organization, data hiding, and associating the code with the data it works on. Those are the big wins of OO for me.

      - tye        

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://670467]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2023-05-31 22:58 GMT
Find Nodes?
    Voting Booth?

    No recent polls found