Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Design patterns....

 
RIO YOU
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 96
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jiafan Zhou
Ranch Hand
Posts: 193
Fedora Linux Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11833
181
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Marcio Aun Migueis
Ranch Hand
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic