wood burning stoves 2.0*
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....

RIO YOU
Greenhorn

Joined: Nov 08, 2005
Posts: 10
I've been thinking of a lot of cases implementing Design-Patterns which are a lot.. @.@;


To be Honest, I couldn't figure out what I choose some of them.

Could u give me some tips which are generally used for this SCJD assign.?

When networking, you better choose the Adapter pattern.
When Data Object, you better select the Singleton pattern.

something like them...

looking forward to your reply. ^^:


Have a good coding~ ^:^
Marcio Aun Migueis
Ranch Hand

Joined: Sep 15, 2003
Posts: 32
RIO,

In my GUI, I use the Observer Pattern to implement a MVC. I have a JFrame ( V ) , and a controller classs( C ). The model ( M ) is the class related to my project. Whe the user click a button, for example, then view send a message ( string ) for the controller class that react accordingly the rules that you defined.

I hope I could help you,

M�rcio
Michael Valentino
Ranch Hand

Joined: Nov 01, 2005
Posts: 96
Depending on your design choices, the patterns you use (if any at all) will vary. Using Adapters and Decorators with RMI is a popular choice, and using Factory patterns with Sockets is also common. You should definitely implement some kind of MVC pattern to separate your GUI presentation from your data access logic: it's good form and decouples the different tiers of the project.

Keep in mind that Design patterns are "tried and true" solutions to common problems faced in coding. You should use a design pattern when 1) you run into one of these problems 2) a simpler solution is not available and 3) the pattern makes sense for what you're doing. I've worked on projects where they thought it was a good idea to string together a whole bunch of design patterns because "design patterns are good!" and made the solution a lot messier and a lot more complex than it needed to be.

My advice is to keep things as simple as possible, and when you come across a problem where a well known pattern will get the job done, go ahead and implement that pattern. I wouldn't do things the other way around and say "Where can I implement those good old patterns?" before you even work towards your solution.

Hope that gives you some insight.


SCJP 1.4, SCWCD J2EE 1.4, SCJD J2SE 1.5, SCBCD J2EE 1.3, SCDJWS (In Progress)
Jiafan Zhou
Ranch Hand

Joined: Sep 28, 2005
Posts: 192

RIO,

In my GUI, I use the Observer Pattern to implement a MVC. I have a JFrame ( V ) , and a controller classs( C ). The model ( M ) is the class related to my project. Whe the user click a button, for example, then view send a message ( string ) for the controller class that react accordingly the rules that you defined.

I hope I could help you,

M�rcio


Why not merge JFrame(V) and Controller class(C) into one class as JFrame(V)?Why complicate things? Can you just create one JFrame(V) class and extract the strings etc?


SCJP, SCJD, SCWCD, SCBCD, SCEA
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

Hi Jiafan,

Originally posted by Jiafan Zhou:
Why not merge JFrame(V) and Controller class(C) into one class as JFrame(V)?Why complicate things? Can you just create one JFrame(V) class and extract the strings etc?
You can do that, however you might have trouble claiming that you are using the Model-View-Controller design pattern if you don't have a Controller (yes, I am aware of the "View-Helper design pattern that is MVC without the C).

Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Marcio Aun Migueis
Ranch Hand

Joined: Sep 15, 2003
Posts: 32
Hi Jiafan,


Why not merge JFrame(V) and Controller class(C) into one class as JFrame(V)?Why complicate things? Can you just create one JFrame(V) class and extract the strings etc?


The main idea behind this is that one class have one responsibility. Separating the JFrame ( View ) from the "actions" ( Controller ) may facilitate the code, and separating the concerns is considerate a good design. I'm working with this concept for a year and I can a affirm that is a great thing.

Regards,

M�rcio
[ November 21, 2005: Message edited by: Marcio Aun Migueis ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Design patterns....
 
Similar Threads
Regarding learning of Java Design Patterns
Pattern V/s Anti-Pattern
Design Pattern in EJB
Design Patterns used in Max's book
Broadly told to learn about patterns