Explain Factory pattern?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is data binding in asp net?

808


What are the advantages of the code-behind feature?

734


What is the use of service provider?

761


List the asp.net validation controls?

699


What is the difference between login controls and forms authentication?

739


Explain client-side scripting?

764


How would you turn off cookies on a page of a website?

680


Name the method that needs to be invoked on the dataadapter control to fill the generated dataset with data?

727


How does http session work?

735


Explain the difference between page.registerclientscriptblock and page.registerstartupscript?

785


Is it possible to change the index of primary key on table?

616


What is meant by web application?

721


What is server side session?

715


What is master page in dtp?

744


To redirect the user to another page which method do we use without performing a round trip to the client?

717