Question

I am working on a registration system. To sign-up for an account, a user must fill out a form. They can register as either an individual or a company. Also, users can choose a registration type such as Pro or Basic.

A company registration includes the individual registration as well, but as a company, you can get a deal so that you get 2 for 1 with certain registration types ( but not all ).

Each of those registration types has a cost associated with them. They are also able to select a region which has a cost associated to each one.

Now if they chose the Basic registration type, it only charges them half the cost of the region.

I am looking for any suggestions on how to approach this seemingly complex registration. I was planning to take an object-oriented approach to this task.

Maybe I am just over-thinking the challenge at hand, but any suggestions or feedback is greatly appreciated.

Was it helpful?

Solution

Account() factory class that returns an AccountIndividual() or AccountCompany() instance.

Account() factory has $type attribute and a list of Registration() objects representing the kinds of registrations associated with a given account.

Registration() factory class that returns two or more RegistrationXYZ() subclasses with appropriate attributes including a $region attribute.

You may or may not need to create a Region() class.

Personally, I would worry about carefully designing the database layer first and then worrying about business logic.

OTHER TIPS

I suggest using a decision table (Table Driven Design). Obviously you should store the prices in some sort of configuration table at any rate.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top