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

Which object is used to encapsulate the state of the client and the browser in ASP.NET?

1 Answers   Sans Pareil IT Services,


What is wrong with a line like this? DateTime.Parse(myString)

5 Answers   Metasys,


How can you achieve nested Masterpages in 2.0?

1 Answers   Microsoft,


What is the difference between pathparam and queryparam?

1 Answers  


why we are using delegates and in which condition it is required?

3 Answers   TCS,


i develop a web application and i gave security setting i.e autherization and athentication now it work properly on my local system , now question is ,is this security setting ie autherization and athentication which i gave in web.config will it be enough strong to secure my application on internet or i have to use some 3rd party tool or software to get security .if yes --how ? if no--what is the alternate?

1 Answers  


How Clustered Index and Non clustered index stored on SQL server?

2 Answers   TCS,


Can I read the hard disk serial # of the client computer using asp.net?

1 Answers  


How do you initiate validation on the server manually? What are two situations when you might you want to do that?

1 Answers  


How to publish website

1 Answers   Syntel,


What is the difference between session state and session variables ?

6 Answers   Digital GlobalSoft,


In Code-Behind class which kind of code (server or client) is found ?

1 Answers   Siebel,


Categories