File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Design patterns

 
rex tony
Ranch Hand
Posts: 159
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good evening to all
Any one can explain the java design pattern very simply, With example
regards
rex
 
Marcus Green
arch rival
Rancher
Posts: 2813
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • 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: 3381
Mac MySQL Database Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As this post has nothing to do with SCJP forum, moderators would move it to the appropriate forum.
 
Henrique Ordine
Ranch Hand
Posts: 128
  • 0
  • Mark post as helpful
  • send pies
  • 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();
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic