Need help on design pattern  
Author Message
lax4u





PostPosted: Architecture General, Need help on design pattern Top

Can somebody help me in deciding the best pattern I should use for following scenario

Here is my scenario.

XYZ is a company with different members. XYZ sign up with different providers.

Each provider needs different information from members. Some of which is common to all providers like first name, last name.

On member enrollment screen, first member will select provider and depend on that provider I'm creating controls dynamically (normally input boxes). This is working fine.

I created member object with all possible information provider needs (object properties in my case). On submit button I’m assigning values from dynamically created controls to member object. My problem is, member object has so many properties and depend on selected provider some properties get values and other properties will be empty. And then I send that object back to DAL layer and eventually to database.

This technique is working fine. But over the period of time there will be new providers who need different information which is not currently in member object, so member object will keep growing.

Now is there any design pattern or technique to solve this issue. I believe there should be since this common real time scenario.

Can somebody give me a link or hint about the best approach I should use



Architecture4  
 
 
Sarit Kommineni





PostPosted: Architecture General, Need help on design pattern Top

This may not be the best but this is one possible solution.

Consider the Factory pattern .

Implement a baseclass/service which handles the common data. This class should implement an interface which has function definitions and properties that are common to all.

Implement derived classes /service extensions which handle the variations from the base data per client.

The factory pattern will let you create the implementation specific to the client when you need it.

The application itself using these classes will be programmed using the interface.

I hope this helps.



 
 
Arnon Rotem Gal Oz





PostPosted: Architecture General, Need help on design pattern Top

Sarit's suggestion is basically correct - you will need, however to work with the concrete types to generate the specific pages (The page has to match the concrete provider).

To solve this problem the basic interface should also include some methods to allow the specific class to describe it self (or use reflection) - this would work with a generic page renderer.

Another option is to also have specific renderers per provider and use the same factory pattern to generate the right renderer.

Arnon



 
 
Kareem Shaker





PostPosted: Architecture General, Need help on design pattern Top

Yes,

This is generally maps to the factory pattern, you can read about it; it's easy to implement, thanks to Polymorphism !

Regards,