?
Solved

Explain Factory and abstract Factory Design Pattern

Posted on 2011-10-18
4
Medium Priority
?
511 Views
Last Modified: 2013-11-24
Explain Factory and abstract Factory Design Pattern
0
Comment
  • 3
4 Comments
 
LVL 4

Expert Comment

by:reijnemans
ID: 36990937
HI,

Check the following url:

http://original.jamesthornton.com/eckel/TIPatterns/html/Chapter06.html

Regards

Reijnemans
0
 
LVL 9

Author Comment

by:Manikandan Thiagarajan
ID: 36990998
could you please explain with own word and example for factory and abstract factory
0
 
LVL 4

Accepted Solution

by:
reijnemans earned 2000 total points
ID: 36991162
The Factory patterns can be used in following cases:

1. When a class does not know which class of objects it must create.
2. A class specifies its sub-classes to specify which objects to create.
3. In programmer’s language (very raw form), you can use factory pattern where you have to create an object of any one of sub-classes depending on the data provided.

example:

public Person getPerson(String name, String gender) {
    if (gender.equals("M"))
        return new Male(name);
    else if(gender.equals("F"))
       return new Female(name);
    else
       return null;
}

Open in new window

0
 
LVL 4

Expert Comment

by:reijnemans
ID: 36991174
Abstract Factory patterns:

One of the main advantages of Abstract Factory Pattern is that it isolates the concrete classes that are generated. The names of actual implementing classes are not needed to be known at the client side. Because of the isolation, you can change the implementation from one factory to another.

example could be the same as a normal factory pattern but with a abstract-factory the super class of the objects is abstract
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses
Course of the Month14 days, 1 hour left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question