Design Patterns Introduction General and reusable solutions to common problems in software design SoftUni Team Software University

Slides:



Advertisements
Similar presentations
Design Patterns.
Advertisements

CS590L - Lecture 6 1 CS590L Distributed Component Architecture References: - E. Gamma, R. Helm, R. Johnson, J. Vlissides, Design Patterns: Elements of.
Plab – Tirgul 12 Design Patterns
(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 and Programming Patterns Associated with Java Networking by Margaret Toews cs843, Spring 2003.
Design Patterns CS is not simply about programming
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Design Patterns.
(c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.
Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Introduction to software design patterns For CSE 3902 By: Matt Boggus.
 Dimitar Ivanov Introduction to programming with microcontrollers.
AngularJS Services Built-in and Custom Services SoftUni Team Technical Trainers Software University
Design Patterns: Introduction. Creational Design Patterns General and reusable solutions to common problems in software design Software University
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
Project Tracking Tools Trello, Asana, Basecamp, GitHub Issue Tracker, TRAC SoftUni Team Technical Trainers Software University
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Software Testing Lifecycle Exit Criteria Evaluation, Continuous Integration Ivan Yonkov Technical Trainer Software University.
Teamwork and Personal Skills Course Introduction Software University SoftUni Team Technical Trainers.
Design Patterns: Structural Design Patterns
Creational Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Powerpoint Templates Page 1 Powerpoint Templates What is Design Patterns ? by Indriati Teknik Informatika – UB.
General and reusable solutions to common problems in software design Vasil Dininski Telerik Software Academy academy.telerik.com Intern at Telerik Academy.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 27. Review UML dynamic view – State Diagrams.
High-Quality Programming Code Code Correctness, Readability, Maintainability, Testability, Etc. SoftUni Team Technical Trainers Software University
JavaScript Design Patterns Private Fields, Module, Revealing Module, Revealing Prototype, … Software University Technical Trainers SoftUni.
Start Your Own Blog Angel Georgiev Part-time Trainer angeru.softuni-friends.org Software University The Culture of Knowledge Sharing.
Svetlin Nakov Technical Trainer Software University
Build Processes and Continuous Integration Automating Build Processes Software University Technical Trainers SoftUni Team.
Project Tracking Tools Trello, Asana, Basecamp, GitHub Issue Tracker, TRAC Angel Georgiev Part-time Trainer Software University
DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
Test-Driven Development Learn the "Test First" Approach to Coding SoftUni Team Technical Trainers Software University
Design Principle & Patterns by A.Surasit Samaisut Copyrights : All Rights Reserved.
ECE450S – Software Engineering II
Asynchronous Web Services Writing Asynchronous Web Services SoftUni Team Technical Trainers Software University
Jekyll Static Site Generator Template-Based Site Generation Svetlin Nakov Technical Trainer Software University
JavaScript Modules and Patterns Private Fields, Module, Revealing Module, Revealing Prototype, … Software University Technical Trainers.
Design Patterns Introduction
CS251 – Software Engineering Lectures 18: Intro to DP Slides by Rick Mercer, Christian Ratliff, Oscar Nierstrasz and others 1 و ابتغ فيما آتاك الله الدار.
Responsive Design Design that Adapts to Different Devices SoftUni Team Technical Trainers Software University
High-Quality Programming Code Code Correctness, Readability, Maintainability Svetlin Nakov Technical Trainer Software University
Design Patterns: Structural Design Patterns General and reusable solutions to common problems in software design Software University
Mocking with Moq Tools for Easier Unit Testing SoftUni Team Technical Trainers Software University
Design Patterns: Behavioral Design Patterns General and reusable solutions to common problems in software design Software University
Mocking with Moq Mocking tools for easier unit testing Svetlin Nakov Technical Trainer Software University
1 Good Object-Oriented Design Dr. Radu Marinescu Lecture 4 Introduction to Design Patterns.
Test-Driven Development Learn the "Test First" Approach to Coding Svetlin Nakov Technical Trainer Software University
Sets, Dictionaries SoftUni Team Technical Trainers Software University
High-Quality Code: Course Introduction Course Introduction SoftUni Team Technical Trainers Software University
Functional Programming Data Aggregation and Nested Queries Ivan Yonkov Technical Trainer Software University
Doctrine The PHP ORM SoftUni Team Technical Trainers Software University
Team Work and Personal Skills Course Introduction Angel Georgiev Part-time Trainer Software University
Creating Content Defining Topic, Creating Technical Training Materials SoftUni Team Technical Trainers Software University
Inheritance Class Hierarchies SoftUni Team Technical Trainers Software University
Stacks and Queues Processing Sequences of Elements SoftUni Team Technical Trainers Software University
Generics SoftUni Team Technical Trainers Software University
Asynchronous Programming Writing Asynchronous Code in Java SoftUni Team Technical Trainers Software University
High-Quality Programming Code Code Correctness, Readability, Maintainability, Testability, Etc. SoftUni Team Technical Trainers Software University
Design Patterns: MORE Examples
Design Patterns: Brief Examples
The Object-Oriented Thought Process Chapter 15
Software Design Patterns
Introduction to Design Patterns
Introduction to Design Patterns
Design Patterns Introduction
Object Oriented Design Patterns - Creational Patterns
DESIGN PATTERNS : Introduction
Informatics 122 Software Design II
Presentation transcript:

Design Patterns Introduction General and reusable solutions to common problems in software design SoftUni Team Software University

Table of Contents  What is a Design Pattern?  Why Design Patterns?  Types of Design Patterns  Creational patterns 2

What is a Design Pattern? Name, Problem, Solution and Consequences

4  General and reusable solutions to common problems in software design  Problem/solution pairs within a given context  Not a finished solution  A template or recipe for solving certain problems  With names to identify and talk about them What Design Patterns Are?

5  Patterns deal with  Application and system design  Abstractions on top of code  Relationships between classes or other collaborators  Problems that have already been solved  Patterns are not concerned with  Algorithms  Specific implementation classes What Design Patterns Are? (2)

6  Christopher Alexander  Very successful architect  A Pattern Language: Towns, Buildings, Construction, 1977  Context:  City Planning and Building architectures Origins of Design Patterns “Each pattern describes a problem which occurs over and over again in our environment and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it in the same way twice”.

7  Search for recurring successful designs  Emergent designs from practice  Supporting higher levels of design reuse is quite challenging  Described in Gama, Helm, Johnson, Vlissides 1995 (i.e., “Gang of Four Book”)  Based on work by Christopher Alexander  An Architect on building homes, buildings and towns Origins of Design Patterns (2)

8  Graphical notation is generally not sufficient  In order to reuse design decisions the alternatives and trade-offs that led to the decisions are critical knowledge  Concrete examples are also important  The history of the why, when, and how set the stage for the context of usage Describing Design Patterns Pattern name Intent Also Known As Motivation Applicability Structure Participants Collaborations Consequences Implementation Sample Code Known Uses Related Patterns

9  Design patterns have four essential elements:  Pattern Name  Increases vocabulary of designers  Problem  Intent, context, when to apply  Solution  UML-like structure, abstract code  Consequences  Results and tradeoffs Elements of Design Patterns

10  Used to describe:  A design problem  Its solutions  Its consequences  Increases design vocabulary  Design at a higher level of abstraction  Enhances communication  “The hardest part of programming is coming up with good variable names” Pattern Name

11  Describes when to apply the pattern  Explains the problem and its context  May describe specific design problems and/or object structures  May contain a list of preconditions that must be met before it makes sense to apply the pattern Problem

12  Describes the elements that make up the  Design  Relationships  Responsibilities  Collaborations  Does not describe specific concrete implementation  Abstract description of design problems and how the pattern solves it Solution

13  Results and trade-offs of applying the pattern  Critical for:  Evaluating design alternatives  Understanding costs  Understanding benefits  Includes the impacts of a pattern on a system’s:  Flexibility, Extensibility, Portability Consequences

Why Design Patterns?

15  Design patterns enable large-scale reuse of software architectures  Help document how systems work  Patterns explicitly capture expert knowledge and design trade- offs  Patterns help improve developer communication (shared language)  Pattern names form a common vocabulary  Patterns help ease the transition to OO technology Benefits of Design Patterns

16  Solutions to problems that recur with variations  No need for reuse if problem only arises in one context  Solutions that require several steps:  Not all problems need all steps  Patterns can be overkill if solution is a simple linear set of instructions!  Do not use patterns when not required  Overdesign is evil! When to Use Patterns?

17  Patterns do not lead to a direct code reuse  Patterns are deceptively simple  Teams may suffer from pattern overload  Patterns are validated by experience and discussion rather than by automated testing  Integrating patterns into the software development process is a human-intensive activity  Use patterns if you understand them well Drawbacks of Design Patterns

18  Targets the wrong problem  The design patterns may just be a sign of some missing features of a given programming language  Lacks formal foundations  The study of design patterns has been excessively ad-hoc  Leads to inefficient solutions  Does not differ significantly from other abstractions Criticism of Design Patterns

Types of Design Patterns

20  Creational patterns  Deal with initializing and configuring classes and objects  Structural patterns  Describe ways to assemble objects to implement a new functionality  Composition of classes or objects  Behavioral patterns  Deal with dynamic interactions among societies of classes and objects  How they distribute responsibility Three Main Types of Patterns

Creational Patterns

22  Deal with object creation mechanisms  Trying to create objects in a manner suitable to the situation  Composed of two dominant ideas  Encapsulating knowledge about which concrete classes the system uses  Hiding how instances of these concrete classes are created and combined Creational Patterns

23  The Singleton class is a class that is supposed to have only one (single) instance  Sometimes Singleton is wrongly thought of as a global variable – it is not!  Possible problems:  Lazy loading  Thread-safe Singleton

24  This is not a Pattern  Often mistaken with the Factory Pattern  It is used quite often  This is the preparation for the real Pattern  Export the object creation in one place  If we are making changes, we make them in one place  We can hide complex object creation  Higher level of abstraction Simple Factory

25  Objects are created by separate method  Produces objects as normal Factory  This allows achieving higher reusability and flexibility in the changing applications Factory Method

26  Abstraction in object creation  Create a family of related objects  The Abstract Factory Pattern defines interface for creating sets of linked objects  Without knowing their concrete classes  Used in systems that are frequently changed  Provides flexible mechanism for replacement of different sets Abstract Factory

27  Separates the construction of a complex object from its representation so that the same construction process can create different representations  Separation of logic and data  Solves 3 types of problems  Too many parameters  Order dependent  Different constructions The Builder Pattern

28  Builder is used by Director  Builder is implemented by a concrete builder  Product is produced by the concrete builder The Builder Pattern (2) Director Builder Concrete Builder Product Define the steps Put the steps in the right order Defines the implementation

29  Factory for cloning new instances from a prototype  Create new objects by copying this prototype  Instead of using "new" keyword  ICloneable interface acts as Prototype Prototype Pattern

30  Object Pool  Avoid expensive acquisition and release of resources by recycling unused objects  Lazy initialization  Tactic of delaying the creation of an object, the calculation of a value, or some other expensive process until the first time it is needed Other Creational Patterns

? ? ? ? ? ? ? ? ? Design Patterns I

License  This course (slides, examples, demos, videos, homework, etc.) is licensed under the "Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International" licenseCreative Commons Attribution- NonCommercial-ShareAlike 4.0 International 32  Attribution: this work may contain portions from  "High Quality Code" course by Telerik Academy under CC-BY-NC-SA licenseHigh Quality CodeCC-BY-NC-SA

Free Software University  Software University Foundation – softuni.orgsoftuni.org  Software University – High-Quality Education, Profession and Job for Software Developers  softuni.bg softuni.bg  Software Facebook  facebook.com/SoftwareUniversity facebook.com/SoftwareUniversity  Software YouTube  youtube.com/SoftwareUniversity youtube.com/SoftwareUniversity  Software University Forums – forum.softuni.bgforum.softuni.bg