• 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

Java Design patterns

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good evening to all
Any one can explain the java design pattern very simply, With example
regards
rex
 
arch rival
Posts: 2813
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Design patterns are not on the SCJP book, and even if they were it is a subject far to big for a single post. Why not see if you can find an appropriate forum and then ask a more specific question.
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moreover, Design Pattern is not a single and simple thing to be explained in a single post.

Design Pattern is an abstract term for a proven solution which solves the common problem in an efficient manner. There are many problems faced, many solutions as well thereby you get many Design Patterns.

You may please refer this link for a good start. Perhaps, a Google Search would also help!
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As this post has nothing to do with SCJP forum, moderators would move it to the appropriate forum.
 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An example of one of the simplest design patterns (in my opinion):

The Singleton

Problem: you need to restrict instantiation of a class to one object.

Exampe implementation:

public class MyClass {
/*Private constructor suppresses generation of a (public) default constructor*/
private MyClass() {}

/**
* instance is loaded on the first execution of Singleton.getInstance()
*/

private static MyClass instance;

public static MyClass getInstance()
{
if (instance == null)
instance = new MyClass();
return instance;
}
}

All client code would have access to the same object by calling:
MyClass.getIntance();
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bruce Eckell has a patterns book using Java. SeeThinking In Patterns.

It's good to have a good overview knowledge of these things so you can recognize problems that have pattern solutions. If you have a pretty good idea of what each one is for, you can find it and dig out the details when you really need it. After a while you'll learn to spot things in your code that resemble some pattern or other, and maybe bend your design in that direction to make it easier for future readers to spot.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic