File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Abstract Factory or Factory Method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Abstract Factory or Factory Method" Watch "Abstract Factory or Factory Method" New topic
Author

Abstract Factory or Factory Method

Jane Wang
Greenhorn

Joined: Mar 07, 2002
Posts: 16
In my design, I create a DataAccess Interface, two classes LocalDataAccess and RemoteDataAccess implement the interface. The LocalDataAccess passes on the calls to Data while the RemoteDataAccess passes on the calls to remote interface.
My first question is: I believe I use the Factory pattern but I am not sure it is Factory Method or Abstract Factory ? Because I have some confusion on them.
My second question is: is there any other design patten appear in my design?
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Nobody can tell whether you are using the Abstract Factory or Factory Method pattern unless you tell us how are you instantiating the DataAccess object (LocalDataAccess or RemoteDataAccess).
Check out this site:
http://www.dofactory.com/patterns/patterns.asp#list
They have brief descriptions of both the Abstract Factory pattern and Factory Method pattern.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Jane Wang
Greenhorn

Joined: Mar 07, 2002
Posts: 16
Thanks for the reference.

Nobody can tell whether you are using the Abstract Factory or Factory Method pattern unless you tell us how are you instantiating the DataAccess object

There is an attribute named db in LocalDataAccess and RemoteDataAccess. For LocalDataAccess, db connects to local data file while for RemoteDataAccess, db connects to remote data base. A class named Service has an attribute named db of DataAccess Interface,when user chooses the connection mode, a method in service will instance the specific child class.
[ September 11, 2002: Message edited by: Jane Wang ]
[ September 11, 2002: Message edited by: Jane Wang ]
Forrest Xu
Greenhorn

Joined: Jan 30, 2002
Posts: 26
I belive you use Abstract Factory
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Abstract Factory or Factory Method
 
Similar Threads
Design issues
Database Designs
FBN: Which classes in which package?
Design Opinion
lock on local client