Your SlideShare is downloading. ×
  • Like
What is Design Pattern and Which Design Pattern implement in my project
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

What is Design Pattern and Which Design Pattern implement in my project

  • 467 views
Published

A design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. A design pattern is not a finished design that can be transformed directly …

A design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. A design pattern is not a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations. So patterns are formalized best practices that you must implement yourself in your application.

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
467
On SlideShare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
14
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Design Pattern – What is design pattern? When we should usedesign pattern? Where we should use design pattern?A design pattern is a general reusable solution to a commonly occurring problem within a givencontext in software design. A design pattern is not a finished design that can be transformeddirectly into code. It is a description or template for how to solve a problem that can be used inmany different situations. So patterns are formalized best practices that you must implementyourself in your application.Creational Design Patterns:Singleton - Ensure that only one instance of a class is created and Provide a global access pointto the object.When we should use - Singleton pattern should be used when we must ensure that only oneinstance of a class is created and when the instance must be available through all the code. Aspecial care should be taken in multithreading environments when multible threads mustaccess the same resources through the same singleton objectWhere we should use- - Configuration, Database and Logger ClassesFactory - Creates objects without exposing the instantiation logic to the client and Refers to thenewly created object through a common interface.When we should use: - a framework delegate the creation of objects derived from a commonsuperclass to the factory - we need flexibility in adding new types of objects that must becreated by the classWhere we should use- Database connectivity[MYSQL,ORACLE and SQL Serverr], XML Parsing[With different xml parser], Sever connectivity[FTP,SCP or Other] Factory Method - Defines an interface for creating objects, but let subclasses to decidewhich class to instantiate and Refers to the newly created object through a common interface. Abstract Factory- Offers the interface for creating a family of related objects, withoutexplicitly specifying their classes.Builder - Defines an instance for creating an object but letting subclasses decide which class toinstantiate and Allows a finer control over the construction process.Prototype - Specify the kinds of objects to create using a prototypical instance, and create newobjects by copying this prototype.Object Pool - reuses and shares objects that are expensive to create..Behavioral Design Patterns:Chain of Responsibiliy - It avoids attaching the sender of a request to its receiver, giving thisway other objects the possibility of handling the request too. The objects become parts of achain and the request is sent from one object to another across the chain until one of theobjects will handle it.Command - Encapsulate a request in an object, Allows the parameterization of clients withdifferent requests and Allows saving the requests in a queue.nterpreter - Given a language, define a representation for its grammar along with an interpreterthat uses the representation to interpret sentences in the language / Map a domain to alanguage, the language to a grammar, and the grammar to a hierarchical object-oriented design
  • 2. Iterator - Provide a way to access the elements of an aggregate object sequentially withoutexposing its underlying representation.Mediator - Define an object that encapsulates how a set of objects interact. Mediator promotesloose coupling by keeping objects from referring to each other explicitly, and it lets you varytheir interaction independently.Observer - Define a one-to-many dependency between objects so that when one objectchanges state, all its dependents are notified and updated automatically.Strategy - Define a family of algorithms, encapsulate each one, and make theminterchangeable. Strategy lets the algorithm vary independently from clients that use it.Template Method - Define the skeleton of an algorithm in an operation, deferring some stepsto subclasses / Template Method lets subclasses redefine certain steps of an algorithm withoutletting them to change the algorithms structure.Visitor - Represents an operation to be performed on the elements of an object structure /Visitor lets you define a new operation without changing the classes of the elements on which itoperates.Structural Design Patterns:Adapter - Convert the interface of a class into another interface clients expect. / Adapter letsclasses work together, that could not otherwise because of incompatible interfaces.Bridge - Compose objects into tree structures to represent part-whole hierarchies. / Compositelets clients treat individual objects and compositions of objects uniformly.Composite - Compose objects into tree structures to represent part-whole hierarchies. /Composite lets clients treat individual objects and compositions of objects uniformly.Decorator - add additional responsibilities dynamically to an object.Resources - http://www.oodesign.com/