• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Design patterns....

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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~ ^:^
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 193
Mac OS X Fedora Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Come have lunch with me Arthur. Adventure will follow. This tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic