I’m in a project where it’s pretty much my first time doing all the architecture myself, and I’m running into a frustrating situation. My architecture for forms seems to be correct from a heuristic perspective, but I don’t think its implementation is correct.
My architecture is thus:
Base Class: OrderForm
Child Classes: PurchaseOrder, Invoice, Credit
Child Class of PurchaseOrder: StockingOrder
Architecturally this makes sense (to me) because all the child classes are OrderForms (“is a”) and a Stocking Order “is a” Purchase Order, just a special kind.
PROBLEM
While coding my StockingOrder class, I’ve noticed that I’ve had to Shadow most if not all of the methods I want to use from PurchaseOrder since they conceptually do the same thing but require slightly different implementation functionality. This, of course, smells to me, but I don’t know how to fix it. What am I doing wrong? Or is this normal?(!)
Thanks…
It sounds like you might need some virtual methods in PurchaseOrder. Maybe something like the following:
This should help to reuse more code as you could group the similar logic you are writing in the PurchaseOrder DoSomethingMethod while keepin the specialized logic (that is different between PurchaseOrder and StockingOrder) in your virtual DoSomethingElse method.