Jump to content

  • Log In with Google      Sign In   
  • Create Account


#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