This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Abstract Factory or Factory Method

 
Jane Wang
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jane Wang
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I belive you use Abstract Factory
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic