Design Patterns Imran Rashid CTO at ManiWeber Technologies.

Slides:



Advertisements
Similar presentations
Design Patterns based on book of Gang of Four (GoF) Erich Gamma, Richard Helm, Ralph Johnson, and John VlissidesGang of Four (GoF) Elements of Reusable.
Advertisements

GoF State Pattern Aaron Jacobs State(305) Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.
Lecture 9 Design Patterns CSCI – 3350 Software Engineering II Fall 2014 Bill Pine.
Copyright W. Howden1 Singleton, Wrapper, and Facade Patterns CSE 111.
SE2811 Week 7, Class 2 The Gang of Four and more … Lab Thursday: Quiz SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder.
Plab – Tirgul 12 Design Patterns
Design Patterns for Object Oriented systems CSC 515 Ashwin Dandwate.
Design Patterns Yes, they are important Robert Cotton April 23, 2009.
05/26/2004www.indyjug.net1 Indy Java User’s Group June Knowledge Services, Inc.
(c) 2009 University of California, Irvine – André van der Hoek1June 13, 2015 – 21:42:16 Informatics 122 Software Design II Lecture 8 André van der Hoek.
Design Patterns CS is not simply about programming
Design Patterns. What are design patterns? A general reusable solution to a commonly occurring problem. A description or template for how to solve a problem.
James Tam Introduction To Design Patterns You will learn about design techniques that have been successfully applied to different scenarios.
Spring 2010CS 2251 Design Patterns. Spring 2010CS 2252 What is a Design Pattern? "a general reusable solution to a commonly occurring problem in software.
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
Design Patterns.
CSSE 374: Introduction to Gang of Four Design Patterns
Advanced topics in software engineering CSC532 Term Paper Design Patterns Harpreet Singh Submitted By:-
Advanced Programming Rabie A. Ramadan 7.
DaveAndAl.net Do Application Design Patterns Make Sense in ASP.NET? Alex Homer You may like to write these down now...
Aniruddha Chakrabarti
January 12, Introduction to Design Patterns Tim Burke References: –Gamma, Erich, et. al. (AKA, The Gang of Four). Design Patterns: Elements of Reusable.
Creational Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Patterns in programming 1. What are patterns? “A design pattern is a general, reusable solution to a commonly occurring problem in software. A design.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 27. Review UML dynamic view – State Diagrams.
CSE 432: Design Patterns Introduction What’s a Pattern? What’s an Idiom? According to Alexander, a pattern: –Describes a recurring problem –Describes the.
CSE 403, Spring 2008, Alverson Software Design “There are two ways of constructing a software design: one way is to make it so simple that there are obviously.
Design Principle & Patterns by A.Surasit Samaisut Copyrights : All Rights Reserved.
Design Patterns -- Omkar. Introduction  When do we use design patterns  Uses of design patterns  Classification of design patterns  Creational design.
05/26/2004www.indyjug.net1 Indy Java User’s Group May Knowledge Services, Inc.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Design Patterns: Elements of Reusable Object- Orientated Software Gamma, Helm, Johnson, Vlissides Presented By: David Williams.
Design Patterns. 1 Paradigm4 Concepts 9 Principles23 Patterns.
Design Patterns Introduction
CS251 – Software Engineering Lectures 18: Intro to DP Slides by Rick Mercer, Christian Ratliff, Oscar Nierstrasz and others 1 و ابتغ فيما آتاك الله الدار.
Game Programming Patterns From the book by Robert Nystrom
Design Patterns CSCE 315 – Programming Studio Spring 2013.
1 Lecture Material Design Patterns Visitor Client-Server Factory Singleton.
Patterns in programming
Introduction To Design Patterns
Design Patterns Source: “Design Patterns”, Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides And Created.
Design Patterns: MORE Examples
CompSci 280 S Introduction to Software Development
Unit II-Chapter No. : 5- design Patterns
The Object-Oriented Thought Process Chapter 15
Chapter 10 Design Patterns.
Chapter 5:Design Patterns
MPCS – Advanced java Programming
Introduction to Design Patterns
Introduction to Design Patterns
Design Patterns Introduction
Introduction To Design Patterns
object oriented Principles of software design
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
Advanced Programming Behnam Hatami Fall 2017.
Software Engineering Lecture 7 - Design Patterns
Introduction to Design Patterns Part 1
Informatics 122 Software Design II
Object Oriented Design Patterns - Creational Patterns
What is Singleton Category: Creational pattern
DESIGN PATTERNS : Introduction
CMPE 135 Object-Oriented Analysis and Design March 21 Class Meeting
Advanced ProgramMING Practices
Introduction to Design Patterns
Advanced ProgramMING Practices
Informatics 122 Software Design II
Introduction To Design Patterns
Composite Design Pattern By Aravind Reddy Patlola.
Software Design Lecture : 27.
Presentation transcript:

Design Patterns Imran Rashid CTO at ManiWeber Technologies

Outline Introduction to Design Patterns What is Gang of Four (GOF)? Usage of Design Patterns Types of Design Patterns Singleton Pattern Decorator Pattern

Introduction to Design Patterns

Introduction to Design Patterns Design patterns represent the best practices used by experienced object-oriented software developers Design patterns are solutions to general problems that software developers faced during software development These solutions were obtained by trial and error by numerous software developers Design patterns in object oriented world is reusable solution to common software design problems which occur again and again in real world app development "A pattern is a recurring solution to a problem in a context"

What is Gang of Four (GOF)?

What is Gang of Four (GOF)? In 1994, four authors Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides published a book titled “Design Patterns - Elements of Reusable Object-Oriented Software” Initiated the concept of Design Pattern in Software development These authors are known as Gang of Four (GOF) According to these authors design patterns are based on the following principles of object orientated design: Program to an interface not an implementation Favor object composition over inheritance (Has-A vs Is-A)

Usage of Design Patterns

Usage of Design Patterns Design patterns have two main usages in development: Common platform for developers Design patterns provide a standard terminology and are specific to particular scenario For example, a singleton design pattern signifies use of single object so all developers familiar with single design pattern & its usage Best Practices Design patterns have been evolved over a long period of time and they provide best solutions to certain problems faced during software development Learning these patterns helps inexperienced developers to learn software design in an easy and faster way

Types of Design Patterns

Types of Design Patterns As per the design pattern reference book, there are 23 design patterns classified in three categories: Creational Patterns These design patterns provide a way to create objects while hiding the creation logic, rather than instantiating objects directly using new operator This gives program more flexibility in deciding which objects need to be created for a given use case Structural Patterns These design patterns concern class and object composition Concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities

Types of Design Patterns Behavioral Patterns These design patterns are specifically concerned with communication between objects

Singleton Pattern

Singleton Pattern In software engineering, the singleton pattern is a software design pattern that restricts the instantiation of a class to one object This type of design pattern comes under creational pattern as this pattern provides one of the best ways to create an object Characteristics: A single constructor, which is private and parameter-less which prevents other classes from instantiating it (which would be a violation of the pattern) It prevents subclassing - if a singleton can be subclassed once, it can be subclassed twice, and if each of those subclasses can create an instance, the pattern is violated

Singleton Pattern A static variable which holds a reference to the single created instance, if any A public static means of getting the reference to the single created instance, creating one if necessary

Singleton Pattern Singleton.cs

Singleton Pattern Program.cs

Decorator Pattern

Decorator Pattern

Decorator Pattern

Decorator Pattern Decorator pattern allows a user to add new functionality to an existing object without altering its structure This type of design pattern comes under structural pattern as this pattern acts as a wrapper to existing class

Decorator Pattern Characteristics: Component (Vehicle) This is an interface containing members that will be implemented by ConcreteClass and Decorator ConcreteComponent (HondaCity) This is a class which implements the Component interface Decorator (VehicleDecorator) This is an abstract class which implements the Component interface and contains the reference to a Component instance & this class also acts as base class for all decorators ConcreteDecorator (SpecialOffer) This is a class which inherits from Decorator class and provides a decorator for components

Decorator Pattern

Any ?