Link to home
Start Free TrialLog in
Avatar of chudmarek
chudmarek

asked on

Class Hierarchy With Design Patterns

Hi Guys,

I am after a clean and elegant solution to my problem. The solution is simple enough if i want to churn out "bad" code. HOWEVER, I want  a solution which follows design patterns, and SOLID principles. I am trying to improve the quality of my code so will leave it to the OOD experts to produce something clean for me to work with.

Let's Say I have a base object, call it Hotel.


Each Hotel has multiple jurisdictions called J1,J2,J3 . Jurisdictions are not fixed. More jurisdictions may be added later.

Each Jurisdiction Has a Manager called B,W,T. Manager is not fixed. More Managers could be added later.

Each Manager has a MemberType called W,P,D. MemberType is not fixed. More Member Types"could" be added later.

Each Member Type has a MemberLevel. Member Level contains a discount {get; set;} and a totalGroupSize{get; set}
The variable values in MemberLevel are all determined by its hierarchy.

So
Hotel->Jurisdiction->Manger->MemberType->MemberLevel.discount
h1.j1.B.W.R.discount = 0.2
h1.j1.B.W.G.discount = 0.1

What I am after is a clean implementation/class design, conforming to design patterns, SOLID to represent the above.

So if my calling code determines I have a hotel of  jurisdiction of J1, a Manager of B, a MemberType of W, a MemberLevel of R, I need it to calculate the discounts applicable to that hierarchy.

Can't wait to see the responses!!

Regards,

Chud
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial