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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.