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.


#ActualCornstalks

Posted 20 April 2013 - 11:20 AM

So, my question, is how should I implement functionality that isn't always present and I would like to remove from streams that don't use it, while maintaining the relatively simple diamond that exists from BasicStream to InputStream and OutputStream, to InputOutputStream?

Probably not through inheritance. Inheritance should be used to create an "is a" relationship. What you're trying to do violates the Liskov Substitution Principle. Perhaps use components instead of inheritance? You rule out components, but I'm not sure why (you could potentially have a "reading" component, a "writing" component, a "rewinding" component, etc.)

 

Besides, what point is the base class BasicStream? I don't see how it really serves a purpose.


#1Cornstalks

Posted 20 April 2013 - 11:17 AM

So, my question, is how should I implement functionality that isn't always present and I would like to remove from streams that don't use it, while maintaining the relatively simple diamond that exists from BasicStream to InputStream and OutputStream, to InputOutputStream?

Probably not through inheritance. Inheritance should be used to create an "is a" relationship. What you're trying to do violates the Liskov Substitution Principle. Perhaps use components instead of inheritance? You rule out components, but I'm not sure why (you could potentially have a "reading" component, a "writing" component, a "rewinding" component, etc.)


PARTNERS