C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |



My Profile

Gifts

Active Members
TodayLast 7 Days more...







Can any one help me out , Factory classes


Posted Date: 03 Jul 2008      Total Responses: 0

Posted By: tippu       Member Level: Bronze     Points: 1


2. You have two factory classes that both return a generic list of a data object class. Currently you are using a switch statement to call a particular factory depending on some input. Code below the switch depends on getting the list of data objects from different sources, but processing them the same.



List<Product> products = null;

switch (i)

{

case 1:

products = ProductFactory.GetProducts();

break;

case 2:

products = ItemFactory.GetItems();

break;

default:

break;

}

The problem is that if you wanted to add more factories from different sources you would have to rewrite the code for the current builder class, i.e. add more statements to the switch. Since an unknown number of factory calls could be made to get the data objects from different sources (one factory returns from Oracle, one from SQL one from SAP, etc) the code needs to accommodate any new factory sources without having to recode.

Describe how you might accomplish this, write code to show your solution. Be as verbose as needed.




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Post Reply
You must Sign In to post a response.
Next : multi-threaded windows application method, can any help me out this problem
Previous : To Generate Prime No In VB.net
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

teleconferencing service

Contact Us    Privacy Policy    Terms Of Use