Powered by Blogger.
Showing posts with label Designpatterns. Show all posts
Showing posts with label Designpatterns. Show all posts

Head First Design Patterns eBook Download

>> Saturday, June 28, 2014

Normally Computer Science Academic text books are written in highfalutin language. But there is nothing wrong in that to have that type of languge. Here O'Reilly's Head First series breaks the textbook mold with verve.The most successful Head First effort, introducing the point of design patterns, the families of design patterns, and a selection of specific patterns with ease and elegance. 
Head First Design Patterns Download_JavabynataraJ

Head First Design Patterns is a great way to get a good overview (and some meat) about design patterns.

Read more..

AbstractFactory Design Pattern with an Example program

>> Tuesday, May 31, 2011

Creational Patterns - Abstract Factory Pattern

Definition:
  • Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
  • A hierarchy that encapsulates: many possible “platforms”, and the construction of a suite of “products”.
  •  The new operator considered harmful.
Where to use & benefits
  1. Creates families of related or dependent objects like Kit.
  2. Provides a class library of products, exposing interface not implementation.
  3. Needs to isolate concrete classes from their super classes.
  4. A system needs independent of how its products are created, composed, and represented.
  5. Try to enforce a constraint.
  6. An alternative to Facade to hide platform-specific classe.
  7. Easily extensible to a system or a family.
  8. Related patterns include.

Read more..

Decorator Design Pattern with an Example

>> Monday, May 30, 2011

Definition:
               Attach additional responsibilities or functions to an object dynamically or statically. Also known as Wrapper.
Where to use & benefits:
  1. Provide an alternative to subclassing.
  2. Add new function to an object without affecting other objects.
  3. Make a responsibility easily added and removed dynamically.
  4. More flexibility than static inheritance.
  5. Transparent to the object.
  6. Related patterns include  
Decorative Design Pattern with Example_JavabynataraJ
  •  Adapter pattern, which provides a different interface to the object it adapts, whereas a decorator changes an object's responsibilities,

Read more..

Factory Design Pattern with a real time Example

>> Friday, May 27, 2011

The Factory design pattern comes under Creational design pattern.

Definition

Provides an abstraction or an interface and lets subclass or implementing classes decide which class or method should be instantiated or called, based on the conditions or parameters given.

Where to use & benefits
  1. Connect parallel class hierarchies.
  2. A class wants its subclasses to specify the object.
  3. A class cannot anticipate its subclasses, which must be created.
  4. A family of objects needs to be separated by using shared interface.
  5. The code needs to deal with interface, not implemented classes.
  6. Hide concrete classes from the client.
  7. Factory methods can be parameterized.
  8. The returned object may be either abstract or concrete object.
  9. Providing hooks for subclasses is more flexible than creating objects directly.
  10. Follow naming conventions to help other developers to recognize the code structure.

Read more..

Singleton Design Pattern Example Program

>> Tuesday, April 19, 2011

Singleton Design pattern will allow only one object per Class(JVM).
Before Writing Singleton Design pattern you should follow these steps.

#1). create an instance as static and return type as The same class, and it should be assigned as null.

private static Singletonn instance = null;

#2). "Create a Constructor as private" to deny the creation of object from other class.

private Singletonn(){
        
    }

#3). Write a static method to create object for our class.It should be Once for a class.

public static Singletonn getInstance(){

}

#4). At last return the class Object.

Here We are creating the object once only not again and again.The first time created object is returning again when you called.

package javabynataraj.basic;

class Singletonn {
    private static Singletonn instance = null;
    private Singletonn(){
        
    }
    public static Singletonn getInstance(){
        if(instance==null){
            instance = new Singletonn();
        }
        return instance;
    }
}

public class Singleton{
    public static void main(String[] args) {
        System.out.println("before calling ...");
        System.out.println(Singletonn.getInstance());
        System.out.println("Once Called");
        System.out.println(Singletonn.getInstance());
        System.out.println("Second time called");
    }
}
Reference books:

  • Design Patterns : Elements of Reusable Object 

  • DESIGN PATTERNS IN JAVA 2nd  Edition 

  • Data Structures And Algorithms With Object-oriented Design Patterns In Java 1st Edition 

  • Dependency Injection: Design Patterns Using Spring and Guice
  • Read more..

    Different types of Design Patterns

    >> Friday, June 18, 2010

    Software Engineers and Developers choose a design pattern to start a project using particular design pattern to start a project. These are helpful to solve the Specific coding and design problems in the real time projects.
    Design Patterns also called as Reusable Object Oriented Software.
    These are the different types of design patterns used in real time world to develop projects.
    Different Types of design patterns_JavabynataraJ

    Read more..

    Related Posts Plugin for WordPress, Blogger...
    © javabynataraj.blogspot.com from 2009 - 2022. All rights reserved.