Tags

,

Reviewed a project with legacy code base of more than a quarter million lines of code. This legacy project was under re-writing proposal phase.

Designed a proposal with high-level UML activity, component, and class diagrams. And the proposal was adopted later.

After a few days of implementing a C# prototype, I slowly felt the pains of designing domain models without totally understanding the domain first. I used inheritance heavily. The levels of object hierarchies were increased to 5 or 6 or even more, , and the design structure began to show signs of fragile.  I had to spend tons of time to decide where an object belonged to this hierarchical tree, and I began to lose track of what was going on.

I realized I had to change. To model the complexity of domain objects and their hierarchies and relationships, I had to use a different strategy. Here came the design principle – favor composition over inheritance.

In this project, I was able to use this design principle to model the domain objects and finish the prototype successfully.

References:

Composition over Inheritance in wikipedia

 

Advertisements