View RSS Feed

Design Patterns

Java Design Patterns

  1. Singleton - Creational Design Pattern

    by , 11-20-2011 at 06:14 PM (My Java Tips)
    The Singleton Design Pattern is the most commonly used design pattern in Java. The Singleton Design Pattern is a Creational Design Pattern. It governs the instantiation process. Sometimes in programming only one object is required across the system. The Singleton Design Pattern is used to achieve exactly that, that is to restrict instantiation of a class to one object. The Singleton Design Pattern ensures a class has only one instance, and provides a global point of access to it.


    ...
  2. Adapter design pattern

    by , 11-20-2011 at 06:10 PM (My Java Tips)
    A Adapter design pattern is Structural design pattern. It is also called as wrapper pattern or just a wrapper. Some classes could not work together because of incompatible interfaces. An adapter allows classes to work together by wrapping its own interface around that of an already existing class. The adapter also handles the logic necessary to transform data into an appropriate form.


    The adapter design pattern is useful in circumstances where an already existing class provides some ...
  3. The Facade Design Pattern

    by , 11-20-2011 at 06:05 PM (My Java Tips)
    The Facade Design Pattern is a structural design pattern amongst the design patterns. A facade is actually an object. It provides an uncomplicated interface to a larger body of code, for example a class library.


    As a facade has simple and tailored methods for common tasks. A facade can make a software library easier to use and understand. A facade also makes the code that uses the library more readable. A facade assists in developing a more flexible system. It reduces dependencies ...
  4. The Observer Design Pattern

    by , 11-20-2011 at 06:00 PM (My Java Tips)
    The Observer design pattern is a Behavioral design pattern. It is used to observe the state of an object in the program. In Observer pattern object(s) are registered to observe an event that may be raised by the observed object. Simply put the Observer pattern allows one object called the observer to watch another object called the subject.


    The observer pattern can listen to an external event, for example a user action. The observer pattern is also used to create a loose coupling ...
  5. The Strategy Design Pattern in Java

    by , 11-20-2011 at 05:25 PM (My Java Tips)
    The strategy design pattern is one of the most fundamental design pattern. The strategy pattern is a design pattern with the help which algorithms can be selected in a real time. The Strategy pattern is behavioral design pattern. The strategy pattern is very useful when it is needed to swap the algorithms used in an application at runtime.


    The strategy pattern is used to define a family of algorithms, encapsulate each one, and make them interchangeable. The strategy design pattern ...
  6. Design Patterns - Basics

    by , 11-19-2011 at 06:01 PM (My Java Tips)
    A design pattern is an abstraction at a very high level. It is to create common and reusable solutions to the recurring problems. Design Patterns provide solutions to design problems which arise again and again in a certain design situations. As a result design patterns have become immensely popular and are very useful to known design issues and problems.


    There are several ways to use and implement these design patterns. These implementation details are called strategies.
    ...
  7. The Five Tiers in Java EE

    by , 11-19-2011 at 05:57 PM (My Java Tips)
    This post briefly explains the 5 tiers in Java Enterprise Edition.



    Client

    A web browser, a hand held device or an application which remotely accesses the services of an enterprise application are examples of a Client tier. In other words a Client tier can consists of all the types of components that are clients of an enterprise application.

    Presentation

    Filters, Java Servlets, JavaServer Pages, JavaBeans and other utility classes ...
  8. The Intercepting Filter

    by , 11-19-2011 at 05:50 PM (My Java Tips)
    In a client-server environment, a system must be able to handle client requests with different processing needs before sending them to server.


    - The system receives requests from a client with different protocols such as HTTP, FTP, SMTP etc.
    - The system must authorize and authenticate some requests, where as for some requests it is not necessary to authorize and authenticate requests and system can handle such requests directly.
    - From certain requests and responses ...
  9. Singleton Pattern

    by , 11-08-2011 at 05:51 PM (My Java Tips)
    A design pattern describes a proven solution to a recurring problem or in other words it is a template for solving problems. Singleton pattern is a creation pattern.

    As the name denotes there will be only an instance of an object, which is created by this pattern. For example: central configuration object should have only one instance that should be accessible from other parts of application. If we have more than one instances of a central configuration object, then different parts ...
    Categories
    Design Patterns , Java SE
  10. Behavioral Pattern - Iterator Pattern (Example)

    by , 11-07-2011 at 06:45 PM (My Java Tips)
    The aim is to iterate through a collection of data using a common interface and more importantly, underlying implementation should not be known. We have a behavioral design pattern called ‘Iterator Pattern’ for this. I will introduce you to it in this post.


    Iterator should be implemented as an interface. This allows the user to implement it anyway its easier for him/her to return data.
    I will take an example of daily life and will show how to use iterator pattern in that. You ...
    Categories
    Design Patterns
  11. Factory Methods

    by , 06-02-2011 at 07:11 PM (My Java Tips)
    This post lists some facts about factory methods.

    Factory methods are static methods that return an instance of the native class. Some examples from JDK include :

    • LogManager.getLogManager
    • Pattern.compile
    • Collections.unmodifiableCollection
    • Collections.synchronizeCollection
    • Calendar.getInstance


    Factory methods do not have names like constructors and do not need to create a new object upon each invocation. Objects can be cached and reused, if ...