Presentation is loading. Please wait.

Presentation is loading. Please wait.

Welcome to. Who am I? A better way to code Design Patterns ???  What are design patterns?  How many are there?  How do I use them?  When do I use.

Similar presentations


Presentation on theme: "Welcome to. Who am I? A better way to code Design Patterns ???  What are design patterns?  How many are there?  How do I use them?  When do I use."— Presentation transcript:

1 Welcome to

2 Who am I?

3 A better way to code

4 Design Patterns ???  What are design patterns?  How many are there?  How do I use them?  When do I use them?

5 What are design patterns?

6  “Design patterns are recurring solutions to software design problems you find again and again in real-world application development” – dofactory.com

7 What are design patterns?  Design Patterns not only allow you to reuse a code solution, but help provide extensibility, maintainability, and a way for fellow programmers to understand the solution.

8 How many patterns are there?  23 +  Creational Patterns Abstract Factory :- Creates an instance of several families of classes Builder : - Separates object construction from its representation Factory Method :- Creates an instance of several derived classes Prototype :- A fully initialized instance to be copied or cloned Singleton :- A class in which only a single instance can exist

9 How many patterns are there?  Structural Patterns Adapter :- Match interfaces of different classes. Bridge :- Separates an object's abstraction from its implementation. Composite :- A tree structure of simple and composite objects. Decorator :- Add responsibilities to objects dynamically. Façade :- A single class that represents an entire subsystem. Flyweigh t:- A fine-grained instance used for efficient sharing. Proxy :- An object representing another object.

10 How many patterns are there?  Behavioral Patterns Mediator :- Defines simplified communication between classes. Memento :- Capture and restore an object's internal state. Interpreter :- A way to include language elements in a program. Iterator :- Sequentially access the elements of a collection. Chain of Resp : - A way of passing a request between a chain of objects. Command :- Encapsulate a command request as an object. State :- Alter an object's behavior when its state changes. Strategy :- Encapsulates an algorithm inside a class. Observer : - A way of notifying change to a number of classes. Template Method :- Defer the exact steps of an algorithm to a subclass. Visitor :- Defines a new operation to a class without change.

11 Are design patterns new?  Nope! In fact they have been around a long time! “ Design patterns have their roots in the work of Christopher Alexander, a civil engineer who wrote about his experience in solving design issues as they related to buildings and towns. It occurred to Alexander that certain design constructs, when used time and time again, lead to the desired effect.” --developer.com/article.php/1474561

12 What languages can use a design pattern?  Most object oriented languages such as C#, VB, Java, PHP, Action Script 3, JavaScript, C++, Python, Ruby, Perl, et al.

13 How do I use a design pattern?  First is being exposed to what’s there. With 23 common patterns plus the custom ones, there’s plenty to pick from.  Second, getting resources to explain them in enough detail you’ll easily understand them and how they’ll fit your needs.

14 Resources…  Highly recommend for beginners to design patterns.  Breaks things down to make very easy to understand.  http://oreilly.com

15 Resources…  A definitive text on all the design patterns.  GoF  Very deep coverage  http://www.amazon.com

16 Resources…  Another definitive book  Very deep coverage  http://www.amazon.com

17 Resources… www.dofactory.com

18 When do I use a design pattern?  When you see if-else or switch statements – that may need a pattern  When there is a lot of complexity in method(s) reusing the same logic – that may need a pattern  When it is hard to test methods and/or logic – that may need a pattern

19 When do I use a design pattern?  Design patterns should be applied when the problem being solved can be solved using a documented design pattern.  The problem should always come first. Only then should pattern knowledge be applied when coming up with a solution.  Patterns are not solutions looking for a place to use them.  Will the pattern add value and simplify the solution?

20 Encapsulates an algorithm inside a class

21 Strategy Design Pattern -UML Allows one of a family of algorithms to be selected on-the-fly at runtime.

22 Strategy Design Pattern  Allows us to divide up the behaviors  Used to provide a model for quickly updating and changing behaviors as needed  Allows for a wide variety of behaviors without having to maintain a bajillion classes

23 Strategy Design Pattern Time for an example!

24


Download ppt "Welcome to. Who am I? A better way to code Design Patterns ???  What are design patterns?  How many are there?  How do I use them?  When do I use."

Similar presentations


Ads by Google