Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Design patterns

 
Forrest Xu
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe I used some Design patterns in my project. But I am not very sure about it. please help me to check if the following is correct idea:
1) For local database, I use Data class which implements IData that has all database method. for remore databse, the database class I used implements IData. So local/remote database is an object of IData. Based on local mode and remote mode, I get a IData object. Does it mean
I use abstract factory pattern?
2) For remote database, I wrap the Data class.
Does it mean I use adapter pattern?
3) To create an unique database instance, I think
I use singleton pattern?
4) MVC pattern has been used in JTable GUI?
5) please tell me any other Design patterns may use?
Thank you for your help!
 
Forrest Xu
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any one help me?
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Forrest,

then it's a singleton.

4) MVC pattern has been used in JTable GUI?

Probably, but not necessarily. I used java.beans for control, so in the truest sense, I did not use MVC, just MV.

5) please tell me any other Design patterns may use?

That's really tough to answer without knowing your design. Before first reading about design patterns, I was using them as a natural solution to certain programming problems, but had no idea that that's what I was doing. So you too have probably incorporated other patterns in your design. Basic design patterns come in three flavors: Creational, Structural and Behavioral.
Creational Patterns:
  • Abstract Factory
  • Builder
  • Factory
  • Prototype
  • Singleton


  • Structural Patterns:
  • Adapter
  • Bridge
  • Composite
  • Decorator
  • Facade
  • Flyweight
  • Proxy


  • Behavioral Patterns:
  • Chain of Responsibility
  • Command
  • Interpreter
  • Mediator
  • Memento
  • Observer
  • State
  • Strategy
  • Template Method
  • Visitor


  • So take a look at these and see if you may have done something like it somewhere in your design and post another question.
    Hope this helps,
    Michael Morris
    [ September 11, 2002: Message edited by: Michael Morris ]
     
    Michael Morris
    Ranch Hand
    Posts: 3451
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Forrest,
    Sorry for the seeming lack of info in the above reply, but the edit feature here at javaranch SUX worse than the search engine.
    The edit ate half my reply! So let me try to reconstruct the first half:

    1) For local database, I use Data class which implements IData that has all database method. for remore databse, the database class I used implements IData. So local/remote database is an object of IData. Based on local mode and remote mode, I get a IData object. Does it mean
    I use abstract factory pattern?

    I would say yes to that.

    2) For remote database, I wrap the Data class.
    Does it mean I use adapter pattern?

    Well, that depends. The purpose of the Adapter pattern is to convert the interface a class to an interface that clients expect. Why would your clients expect an interface different from Data's public methods? It could be that you are using a Facade pattern instead. For example, if you never call the primative methods like getRecord(), modify(), lock(), etc., from the client but instead call methods like searchDB(), bookFlight(), etc., on the wrapper class which in turn calls the primative methods on Data, then that would be a Facade pattern.

    3) To create an unique database instance, I think
    I use singleton pattern?

    That depends too. If you did something like this:
    (See above for remainder of reply)
    Michael Morris
    [ September 11, 2002: Message edited by: Michael Morris ]
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic