Visual Basic: An Object Oriented Approach 11 – Patterns in object oriented programming.

Slides:



Advertisements
Similar presentations
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.
Advertisements

18-1 Verifying Object Behavior and Collaboration Role playing – the act of simulating object behavior and collaboration by acting out an object’s behaviors.
CS590L - Lecture 6 1 CS590L Distributed Component Architecture References: - E. Gamma, R. Helm, R. Johnson, J. Vlissides, Design Patterns: Elements of.
Design Patterns for Object Oriented systems CSC 515 Ashwin Dandwate.
Patterns Reusable solutions to common object-oriented programming problems When given a programming problem, re-use an existing solution. Gang of Four.
Design Patterns Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
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.
Dept. of Computer Engineering, Amirkabir University of Tech. 1 Design Patterns Dr. Noorhosseini Introduction.
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.
(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 ( ) ( ) ( )
CERN – European Organization for Nuclear Research GS Department – Administrative Information Services Design Patterns in Groovy Nicolas Décrevel Advanced.
Software Waterfall Life Cycle Requirements Construction Design Testing Delivery and Installation Operations and Maintenance Concept Exploration Prototype.
樣式導向設計 (Pattern-Oriented Design) 課程簡介 Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering.
Patterns 1 Patterns in OO - history 77 - Work of the architect Christopher Alexander 80s - Kent Beck playing with Smalltalk 91 - Gamma’s PhD thesis on.
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
January 12, Introduction to Design Patterns Tim Burke References: –Gamma, Erich, et. al. (AKA, The Gang of Four). Design Patterns: Elements of Reusable.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
Object Oriented Software Engineering Chapter 16 and 17 review 2014/06/03.
CSE 403 Lecture 14 Design Patterns. Today’s educational objective Understand the basics of design patterns Be able to distinguish them from design approaches.
Testing Extensible Design Patterns in OO Frameworks through Scenario Templates D.S. Sanders Software Verification & Validation.
Methods: Deciding What to Design In-Young Ko iko.AT. icu.ac.kr Information and Communications University (ICU) iko.AT. icu.ac.kr Fall 2005 ICE0575 Lecture.
ECE450S – Software Engineering II
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
Introduction to Design Patterns. Questions What is a design pattern? Who needs design patterns? How different are classes and objects in APL compared.
1 Design Patterns Object-Oriented Design. 2 Design Patterns 4Reuse of design knowledge and experience 4Common in many engineering disciplines 4Avoids.
Creational Patterns
What to know for the exam. Smalltalk will be used for questions, but there will not be questions about the grammar. Questions might ask – how particular.
FACTORY METHOD. Design Pattern Space Purpose ScopeCreationalStructuralBehavioral ClassFactory MethodAdapterInterpreter Template Method ObjectAbstract.
CS616: Software Engineering Spring 2009 Design Patterns Sami Taha.
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
Design Patterns. 1 Paradigm4 Concepts 9 Principles23 Patterns.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
Design Patterns Introduction
Design Patterns SE464 Derek Rayside images from NetObjectives.com & Wikipedia.
Java Design Patterns Java Design Patterns. What are design patterns? the best solution for a recurring problem a technique for making code more flexible.
CS251 – Software Engineering Lectures 18: Intro to DP Slides by Rick Mercer, Christian Ratliff, Oscar Nierstrasz and others 1 و ابتغ فيما آتاك الله الدار.
Design Patterns in Context ©SoftMoore ConsultingSlide 1.
Five Minute Design Patterns Doug Marttila Forest and the Trees May 30, 2009 Template Factory Singleton Iterator Adapter Façade Observer Command Strategy.
7 April 2004CSci 210 Spring Design Patterns 2 CSci 210.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
The Object-Oriented Thought Process Chapter 15
Chapter 10 Design Patterns.
樣式導向設計 (Pattern-Oriented Design) 課程簡介
Chapter 5:Design Patterns
Software Design Patterns
MPCS – Advanced java Programming
Introduction to Design Patterns
Design Patterns Lecture part 2.
Introduction to Design Patterns
Chapter 8, Design Patterns Bridge
object oriented Principles of software design
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
Design Patterns in Game Design
Informatics 122 Software Design II
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Informatics 122 Software Design II
Chapter 8, Design Patterns Introduction
CIS 644 Tues. Nov. 30, 1999 W15A … patterns.
Chapter 8, DesignPatterns Facade
Presentation transcript:

Visual Basic: An Object Oriented Approach 11 – Patterns in object oriented programming

2 Patterns - Motivation Other disciplines have handbooks Descriptions of successful solutions to known problems e.g. Auto engineers do not start a design from the laws of physics In software, tendency is to build everything that is not an identifiable component from scratch Difficulty in identifying previously developed assemblies

3 What are Design Patterns OOP Gives us classes and objects Reuse possible at class/object level (components) Systems are seldom simple assemblies of these Patterns give us tried and tested ways of interconnecting objects Reuse of algorithms, structures and mechanisms for generating objects Nothing new about patterns Patterns codify experience Experts tend to work with mental models that are higher- order abstractions

4 Sources of Patterns Standard text Gamma, Helm, Jonson & Vlissides Proposes 23 commonly used patterns Examples in C++ and Smalltalk (none in VB, but that’s what this chapter is about) Many other texts now available Most extend the range beyond the original 23 Journals with useful articles on patterns JOOP, Java Report Communications of the ACM Dr. Dobbs Journal

5 Types of Patterns Creational methods for generating objects Structural methods for interconnecting software elements Behavioral methods of performing typical operations

6 Benefits of Patterns Promote reusability not necessarily reusable themselves, but... provide for maximizing polymorphism Well tried patterns are always well defined developed in response to common problems Clarify the core purpose of code high-level abstractions

7 Patterns are Designs - What about implementations? Patterns are general can be implemented in most languages aim is to define good programming practice OOP with inheritance preferred - interface inheritance is (almost) essential In VB, we can develop interfaces that implement the essential features of a pattern Every use of a pattern is different, but draws from the same source as others A Pattern Interface is simple an Interface class that does something needed for the pattern

8 Creational patterns Aim here is to separate the creation of objects from a specific application Factory Method Abstract Factory Prototypes Singleton Builder Each pattern promotes a specific set of design decisions

9 Example of a Creational Pattern: the Factory Method Factory Object Generate(ID) Product Interface Product Class 1Product Class n Application Select Case ID Case 1 Set Generate = New CProduct1 Case 2 Set Generate = New CProduct2 Case…. End Select Application calls the Generate method, and is returned an object that implements the product interface

10 Factory Method Private Function GetNewDrawShape(desc As String) _ As IShape Dim S As IShape Select Case desc Case "Rectangle" Set S = New CRectangle Case "Ellipse" Set S = New CEllipse End Select Set GetNewDrawShape = S End Function ‘desc’ is a string that identifies the required class

11 Structural Patterns Aim is to generalize interconnections between objects Composite Adapter Bridge Decorator Facade Flyweight Proxy Decorator

12 Example of a Structural Pattern: Composite A Drawing A LineA CircleA Group A LineA Circle A LineA Circle A Group IShape Add( ) Remove( ) Draw( ) GetChild( ) CPrimitive Add( ) Remove( ) Draw( ) GetChild( ) CGroup Add( ) Remove( ) Draw( ) GetChild( ) In CPrimitive class, Add, Remove and GetChild do nothing

13 Composite Pattern Interface ‘ IComposite Interface class Public Sub Draw(P As PictureBox) End Sub Public Sub Add(Item As IComposite) End Sub Public Sub Remove(Item As IComposite) End Sub Public Function GetChild(n As integer) As IComposite End Function

14 Behavioural Patterns Aim is to create abstract operations Observer Iterator Chain of Responsibility Command Interpretor Mediator Memento State Strategy Template Method Visitor

15 Example of a Behavioural Pattern CSubject AddObserver(O As CObjerver) Notify( ) Update CObserver For Each o In observers o.Update Next

16 Observer Classes ‘Private Observers As Collection Private Sub Notify() Dim f As Form For Each f In Observers ‘ Send the Update message to each.. f.Update Hour(Time), Minute(Time), Second(Time) Next End Sub Private Sub AddObserver(f As Form) Observers.Add f End Sub

17 Where from here Gamma et al is a good starting point find out how they work find out what their benefits are find out how much effort Try them out Most are simple to implement All have some benefits to them Investigate specialist patterns Real-time, Process scheduling & concurrency, Distributed systems

18 Summary Patterns for reuse well tried solutions best use of OOP/polymorphism Glib statement of the week Don’t write a program - reuse a pattern!