Explain Factory pattern?

Answers were Sorted based on User's Feedback



Explain Factory pattern?..

Answer / swetha

Factory Design Pattern is a simple decision making class
that returns one of several objects depending on the data
provided. It comes under creational type of design pattern.


Example:

Suppose say that want to write the code to perform
arithmetic calculations. Initially you decided to write code
for only Addition and Subtraction. And later on you decided
to add more functionality by including Multiplication and
Division. Now, if you don't use Factory Design Pattern, we
need to change the entire code to include additional
functionality. But, when we use Factory Design Pattern, It
is easy to add additional functionality when needed without
disturbing previous code.

In factory class we create the instance of the classes
addition, subtraction, division and multiplication based on
the operator selected.

In this way Factory Design Pattern is useful.

Is This Answer Correct ?    4 Yes 0 No

Explain Factory pattern?..

Answer / gaurav

For better answer :
http://planetofcoders.blogspot.com/2011/10/can-you-explain-factory-pattern.html

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More ASP.NET Interview Questions

What does the "EnableViewState" property do? Why would I want it on or off?

2 Answers   Photon Infotech, Siebel Systems, Syntax Softtech,


Advantage of data Reader?

2 Answers  


cr8 2 datatables into one dataset DYNAMICALLY (no backend database used like sql,etc.,) with following columns 1st datatable with columns studentNo studentName Deptno 2nd datatable with columns Deptno DeptName DeptAddress add data to both the tables Dynamically and merge these tables into one table and display it in Grid view as studentNo studentName Deptno DeptName DeptAddress

1 Answers   SQL Star,


What is the roll of JIT in asp.net?

7 Answers  


What is an example of an application service provider?

0 Answers  






What are runtime hosts?

4 Answers   Microsoft,


About Usage of server variables ?

2 Answers   Cognizant, CTS,


What are the disadvantages of view state / what are the benefits?

2 Answers   Siebel Systems,


What is a reflection?

0 Answers  


What is session mode in asp.net?

0 Answers  


In what order do the events of an ASPX page execute, As a developer is it important to understand these events?

4 Answers  


Why does my asp.net file have multiple tag with runat=server?

0 Answers  


Categories