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.

Hotel->Jurisdiction->Manger->MemberType-> = 0.2 = 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!!


Who is Participating?
käµfm³d 👽Commented:
There's no clear inheritance heirarchy here, so I don't know which pattern you think would apply. IMO, each thing is a collection belonging to its parent class. Unless there's more to this problem, I can't see how you would need anything more than that.

Now I will say that your second-to-last paragraph kind of sounds like a decorator pattern could work. The problem with decorator is you need to have a generic name for the base class or interface that you use as the foundation of the decorator, and the things you've described above don't really jump out as having anything in common such that it could be used as the base class name.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.