oop question-refactoring and two classes communicating

So I had a complex class that seemed to be doing to much by itself. An order item class. So I refactored into two different classes. An order item class and an order size class.

In an instance like this what do you think about the order size class maintaining a reference to the interface of the order item class. There are several properties of the order item class that I consistently need access to in the order size class.

I know that a child is not supposed to know about the parent but what about in a case like this

Thanks,

Dean.


Answer this question

oop question-refactoring and two classes communicating

  • Piotr Celej

    It's tough to give detailed advice without seeing your object model, but my first reaction is why would OrderSize need to be a separate class I'd think that would just be a property on your Order class.

    The way I usually implement something like this is have an Order class, made up of OrderItems, and if necessary that can be composed of OrderLineItems.

    Hope that helps,

    Jonathan Aneja

    The VB Team



  • oop question-refactoring and two classes communicating