Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualSandman

Posted 21 May 2013 - 05:02 AM

It's kind of an incomplete question as is then. What is the purpose of the Pallet and Carton classes? What does the Objects class do? Why do Pallet and Carton inherit Goods to begin with?


Indeed, there isn't any way to 'favour composition over inheritance' because the inheritance doesn't actually do anything.

The only thing we can really suggest with this example is to stop using inheritance pointlessly and dump the Goods, Pallet and Cartons classes, because they don't do anything besides needlessly deepen your inheritance tree.

EDIT: missed the bit about Pallet and Carton exhibiting different behaviours. That does slightly change things, although it's still difficult to answer clearly without a bit more information about what those behaviour differences are.

#2Sandman

Posted 21 May 2013 - 05:01 AM

It's kind of an incomplete question as is then. What is the purpose of the Pallet and Carton classes? What does the Objects class do? Why do Pallet and Carton inherit Goods to begin with?


Indeed, there isn't any way to 'favour composition over inheritance' because the inheritance doesn't actually do anything.

The only thing we can really suggest with this example is to stop using inheritance pointlessly and dump the Goods, Pallet and Cartons classes, because they don't do anything besides needlessly deepen your inheritance tree.

EDIT: missed the bit about Pallet and Carton exhibiting different behaviours. That does slightly change things, although it's still difficult to answer clearly without a bit more information about what those behaviour differences are.

#1Sandman

Posted 21 May 2013 - 04:49 AM

It's kind of an incomplete question as is then. What is the purpose of the Pallet and Carton classes? What does the Objects class do? Why do Pallet and Carton inherit Goods to begin with?

 

Indeed, there isn't any way to 'favour composition over inheritance' because the inheritance doesn't actually do anything.

 

The only thing we can really suggest with this example is to stop using inheritance pointlessly and dump the Goods, Pallet and Cartons classes, because they don't do anything besides needlessly deepen your inheritance tree.


PARTNERS