Context Objects Evolution of object behavior Behavioral patterns

Slides:



Advertisements
Similar presentations
Lecture 10: Part 1: OO Issues CS 540 George Mason University.
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.
Design Patterns Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
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.
Dept. of Computer Engineering, Amir-Kabir University 1 Design Patterns Dr. Noorhosseini Lecture 2.
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.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Vrije Universiteit amsterdamPostacademische Cursus Informatie Technologie Idioms and Patterns polymorphism -- inheritance and delegation idioms -- realizing.
Programming Languages and Paradigms Object-Oriented Programming.
Design Patterns.
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
Polymorphism, Inheritance Pt. 1 COMP 401, Fall 2014 Lecture 7 9/9/2014.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Design Pattern Interpreter By Swathi Polusani. What is an Interpreter? The Interpreter pattern describes how to define a grammar for simple languages,
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
CS 210 Adapter Pattern October 19 th, Adapters in real life Page 236 – Head First Design Patterns.
Computing IV Singleton Pattern Xinwen Fu.
GoF: Document Editor Example Rebecca Miller-Webster.
Design Patterns CS 124 Reference: Gamma et al (“Gang-of-4”), Design Patterns.
Testing Extensible Design Patterns in OO Frameworks through Scenario Templates D.S. Sanders Software Verification & Validation.
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.
Linzhang Wang Dept. of Computer Sci&Tech, Nanjing University The Strategy Pattern.
DESIGN PATTERNS -BEHAVIORAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1.
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Billy Bennett June 22,  Intent Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.
Design Patterns Introduction
Java Design Patterns Java Design Patterns. What are design patterns? the best solution for a recurring problem a technique for making code more flexible.
The State Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Interface Patterns. Adapter Provides the interface a client expects, using the services of a class with a different interface Note Avoid using object.
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
Example to motivate discussion We have two lists (of menu items) one implemented using ArrayList and another using Arrays. How does one work with these.
Watching the movie the hard way…. Page 256 – Head First Design Patterns.
CS 210 Proxy Pattern Nov 16 th, RMI – A quick review A simple, easy to understand tutorial is located here:
CSE 332: Design Patterns (Part II) Last Time: Part I, Familiar Design Patterns We’ve looked at patterns related to course material –Singleton: share a.
Five Minute Design Patterns Doug Marttila Forest and the Trees May 30, 2009 Template Factory Singleton Iterator Adapter Façade Observer Command Strategy.
Chapter 7 Classes and Methods III: Static Methods and Variables Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition)
COP 4331 – OOD&P Lecture 7 Object Concepts. What is an Object Programming language definition: An instance of a class Design perspective is different.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
JAVA ACCESS MODIFIERS. Access Modifiers Access modifiers control which classes may use a feature. A classes features are: - The class itself - Its member.
Object-Oriented Programming
Design Patterns: MORE Examples
Object-Oriented Design
Unit II-Chapter No. : 5- design Patterns
Chapter 10 Design Patterns.
Software Design Patterns
MPCS – Advanced java Programming
Introduction to Design Patterns
Inheritance and Polymorphism
Behavioral Design Patterns
Design Patterns Based on slides provided by Abbie Jarrett
State pattern – A logical ‘Finite State Machine’
Table of Contents Class Objects.
Types of Programming Languages
object oriented Principles of software design
SNSCT_CSE_PROGRAMMING PARADIGM_CS206
Lecture 8 Style rules: Class graph minimization
Object Oriented Programming
Design Patterns in Game Design
Object Oriented Design Patterns - Structural Patterns
Decorator Pattern Richard Gesick.
Testing with OO OO has several key concepts:
Polymorphism Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2nd edition, by Kernighan.
CS 350 – Software Design Principles and Strategies – Chapter 14
Lecture 8 Evolution of object behavior Behavioral patterns
APPCs revisited 2/25/2019 APPCs revisited.
Chapter 8, Design Patterns Singleton
Jim Fawcett CSE687 – Object Oriented Design Spring 2014
Presentation transcript:

Context Objects Evolution of object behavior Behavioral patterns 2/24/2019 AOOS

Evolution of object behavior What is behind design patterns like: Bridge, Chain of Responsibility, Decorator, Iterator, Observer, State, Strategy, Visitor Dynamic variation of behavior Need patterns since there are not adequate language constructs in programming languages 2/24/2019 AOOS

Context relation Supports dynamic behavioral evolution while maintaining safety and performance benefits Context relation orthogonal to inheritance relation Dynamically alter single object or a class 2/24/2019 AOOS

Context Relation Design patterns Structural and behavioral benefit Creational abstract instantiation process Structural abstract object composition Behavioral abstract object communication and responsibilities Structural and behavioral benefit 2/24/2019 AOOS

Context Relation Dynamically alter an object Dynamically alter a class Bridge, Chain of Responsibility, Strategy, etc. Dynamically alter a class Iterator, Visitor 2/24/2019 AOOS

Context Relation Three basic concepts to safely achieve dynamic behavior at both the object and class level: Instance-stored versus class-stored specification Dynamic specification Dynamic update 2/24/2019 AOOS

Instance-stored versus class-stored Many OO languages distinguish between class variables and methods (static) methods invoked through the class, no implicit this instance variables and methods methods invoked with class instance, implicit this 2/24/2019 AOOS

Instance-stored versus class-stored Both instance and class methods can be considered class-stored: each class has conceptually one virtual method table Java currently only supports class-stored methods Need variations on a per-object basis. 2/24/2019 AOOS

Instance-stored versus class-stored Instance methods may vary on a per-object basis: instance-stored methods Instance methods may vary on a per-class basis: class-stored methods Class methods may vary on a per-class basis 2/24/2019 AOOS

Method declarations 2/24/2019 AOOS

Examples class void f() {/* no this */} void f() { … this … } instance void f() { … this …} 2/24/2019 AOOS

Dynamic specification Specify with context relation Context relation links a class with its dynamic variations Use delta symbol Use Strategy Design pattern as an example (has nothing to do with traversal strategies) 2/24/2019 AOOS

Context relation Composition instance void compose() D SimpleCompositor TexCompositor Composition default void compose(){…} Composition void compose(){…} 2/24/2019 AOOS

Without context relation Composition void compose() {comp.compose(this);} comp Compositor {abstract} void compose(Composition c) SimpleCompositor void compose(Composition c){…} TexCompositor void compose(Composition c){…} 2/24/2019 AOOS

Context classes A context class does not inherit from a base class, nor is it considered a subclass It is also not considered an abstract super class A context class defines instance variables and methods of its instances: it is a class 2/24/2019 AOOS

Design language for Java 2/24/2019 AOOS

Dynamic update Update the methods for an object or class Requires virtual method tables to be dynamic To alter method tables: context attachment attach context object to object or class 2/24/2019 AOOS

Other Design Patterns State an object in different states may react differently to the same message. Without context relation, need association and inheritance. Bridge, Chain of Responsibility, Decorator and Observer can also be simplified with context relation. 2/24/2019 AOOS

Another use of context objects Modify a group of classes for the duration of a method invocation: attach context to method invocation Does this sound or look familiar? 2/24/2019 AOOS

Visitors as special context objects e.visit{inv}(); // inv: inventory visitor the visit method should be executed within the context of the inventory object inv. Updates the application classes for the duration of invocation e.visit(inv); // in Demeter/Java 2/24/2019 AOOS

Alternative view In Demeter/Java we have adaptive methods: A { R f() to X (V1,V2); … } This seems to be the preferred way of programming by the Demeter/Java team. This style is about class level behavior modifications and does not have to use visitor objects for implementation. 2/24/2019 AOOS

How can we improve adaptive methods? Need mechansim to communicate between visitors. 2/24/2019 AOOS