This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Design patterns Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Design patterns" Watch "Design patterns" New topic
Author

Design patterns

Forrest Xu
Greenhorn

Joined: Jan 30, 2002
Posts: 26
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

Joined: Jan 30, 2002
Posts: 26
any one help me?
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
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 ]

    Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
    Michael Morris
    Ranch Hand

    Joined: Jan 30, 2002
    Posts: 3451
    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 ]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Design patterns
     
    Similar Threads
    release the critics, here comes a design
    What If i don't use any Design Patterns?
    Database connection type return problem
    NX SCJD: but passed with 155/155
    Design questions (with RMI)