CSE 432: Thanks for the memory leaks, Pushme-Pullyu, and Command Summary of “Thanks for the Memory Leaks” “Left-over” design forces from Type Laundering.

Slides:



Advertisements
Similar presentations
MicroKernel Pattern Presented by Sahibzada Sami ud din Kashif Khurshid.
Advertisements

CPU Review and Programming Models CT101 – Computing Systems.
CSE 432: Course Summary Course Summary: CSE specific GoF/PH design patterns’ structure & content How requirements, design forces, and patterns interact.
Broker Pattern Pattern-Oriented Software Architecture (POSA 1)
Computer Science 313 – Advanced Programming Topics.
Reza Gorgan Mohammadi AmirKabir University of Technology, Department of Computer Engineering & Information Technology Advanced design.
Software Design & Documentation – Design Pattern: Command Design Pattern: Command Christopher Lacey September 15, 2003.
Design Patterns CS is not simply about programming
Façade Design Pattern Source: Design Patterns – Elements of Reusable Object- Oriented Software; Gamma, et. al.
Reuse Activities Selecting Design Patterns and Components
BY VEDASHREE GOVINDA GOWDA
BDP Behavioral Pattern. BDP-2 Behavioral Patters Concerned with algorithms & assignment of responsibilities Patterns of Communication between Objects.
1 Chapter Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer.
CSE 332: Design Patterns (Part I) Introduction to Design Patterns Design patterns were mentioned several times so far –And the Singleton Pattern was discussed.
SOFTWARE DESIGN AND ARCHITECTURE
“A labor of love” (Multicast Pattern) Chapter 4 (pages or ) Chris Gordon.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Reactor Design Patterns: Command and Observer.
Lecture Set 11 Creating and Using Classes Part B – Class Features – Constructors, Methods, Fields, Properties, Shared Data.
Command. RHS – SOC 2 Executing a command Executing a command appears simple at first, but many details to consider: –Who creates a command? –Who invokes.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VII Observer, Command, and Memento.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
Lexi case study (Part 2) Presentation by Matt Deckard.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
Chapter 8 Object Design Reuse and Patterns. Object Design Object design is the process of adding details to the requirements analysis and making implementation.
Object Oriented Software Engineering Chapter 16 and 17 review 2014/06/03.
CSE 432: Design Patterns Introduction What’s a Pattern? What’s an Idiom? According to Alexander, a pattern: –Describes a recurring problem –Describes the.
Processes Introduction to Operating Systems: Module 3.
Structural Design Patterns
Linzhang Wang Dept. of Computer Sci&Tech, Nanjing University The Command Pattern.
CSE 332: Design Patterns Review: Design Pattern Structure A design pattern has a name –So when someone says “Adapter” you know what they mean –So you can.
Review of Stacks and Queues Dr. Yingwu Zhu. How does a Stack Work? Last-in-First-out (LIFO) data structure Adding an item Push operation Removing an item.
DESIGN PATTERNS -BEHAVIORAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1.
FacadeDesign Pattern Provide a unified interface to a set of interfaces in a subsystem. Defines a high level interface that makes the subsystem easier.
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
CSE 332: Design Patterns Review: Design Pattern Structure A design pattern has a name –So when someone says “Adapter” you know what they mean –So you can.
Using Software Design Patterns Bill Anderson. About me Fox developer since 1987 Fox developer since 1987 Program Director, Los Angeles Visual Foxpro Developers.
BEHAVIORAL PATTERNS 13-Sep-2012 Presenters Sanjeeb Kumar Nanda & Shankar Gogada.
Secure middleware patterns E.B.Fernandez. Middleware security Architectures have been studied and several patterns exist Security aspects have not been.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Venkita Subramonian, Christopher Gill, Ying Huang, Marc Sentany Department of Computer Science.
Engineering Classes. Objectives At the conclusion of this lesson, students should be able to: Explain why it is important to correctly manage dynamically.
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.
Behavioural Patterns GoF pg Iterator GoF pg. 257 – 271 Memento GoF pg By: Dan Sibbernsen.
Duke CPS Programming Heuristics l Identify the aspects of your application that vary and separate them from what stays the same ä Take what varies.
The Command Pattern SE-2811 Dr. Mark L. Hornick 1.
Command. RHS – SWC 2 Executing a command Executing a command appears simple at first, but many details to consider: –Who creates a command? –Who invokes.
Layers Architecture Pattern Source: Pattern-Oriented Software Architecture, Vol. 1, Buschmann, et al.
PIMPL Idiom Encapsulating Implementation. Forward Declaration Revisited forward class declaration – names the class, does not provide definition class.
Command Pattern. Intent encapsulate a request as an object  can parameterize clients with different requests, queue or log requests, support undoable.
Engineered for Tomorrow Unit:8-Idioms Engineered for Tomorrow sharmila V Dept of CSE.
Strategy: A Behavioral Design Pattern
Abstract Factory Pattern
Processes and threads.
Jim Fawcett CSE776 – Design Patterns Summer 2005
Turning method call into an object
MPCS – Advanced java Programming
Behavioral Design Patterns
Delegates and Events 14: Delegates and Events
Observer Design Pattern
object oriented Principles of software design
Programming Design Patterns
Doug Jeffries CS490 Design Patterns May 1, 2003
The Active Object Pattern
Jim Fawcett CSE776 – Design Patterns Summer 2003
Patterns.
Half-Sync/Half-Async (HSHA) and Leader/Followers (LF) Patterns
PH Chapter 3 Thanks for the Memory Leaks Pushme-Pullyu (pp
Design Patterns Part 2: Factory, Builder, & Memento
Structural Patterns: Adapter and Bridge
12. Command Pattern SE2811 Software Component Design
Software Engineering and Architecture
Presentation transcript:

CSE 432: Thanks for the memory leaks, Pushme-Pullyu, and Command Summary of “Thanks for the Memory Leaks” “Left-over” design forces from Type Laundering –Need to avoid leaking dynamically created cursors –Cannot predict when clients will obtain/release them Solution: handle-body idiom (similar to Bridge) –Body role is played by CursorImp (implementation) Performs reference counting in the ref/unref methods This is another idiom: “last one out turn off the lights” –Handle role is played by Cursor (interface) Call ref/unref reference counting methods correctly User can copy, destroy, etc. handles at will Important details matter like return-by-value in cursor()

CSE 432: Thanks for the memory leaks, Pushme-Pullyu, and Command Summary of “Pushme-Pullyu” Pull (client calls) vs. push (client called) events –Active vs. passive, blocking vs. callback, etc. –Important question: “locus of control” Push simplifies consumer, increases producer complexity Pull simplifies producer, increases consumer complexity Design forces –Different events have disjoint interfaces –Want to deliver events in a type safe way –Let applications define new events transparently Solution –Handlers register for events, can be combined as “mix ins” –Handlers provide event-type-specific handle methods Similarities to: CoR, Mediator, Multicast (on Wed) Common in publish/subscribe, event channel systems

CSE 432: Thanks for the memory leaks, Pushme-Pullyu, and Command Review of Command Pattern (from 1 st Lecture) Problem –Want to issue requests to objects –Don’t know in advance which request(s) will be made –Don’t know in advance to what object(s) they will go Solution core –Encapsulate function call parameters and target object reference inside an “execute” method (or operator() ) Consequences –Decouples invocation/execution –Commands are first-class objects (elevates functions) –Easy to compose, add new ones Examples of know uses –STL function objects, items in undo stacks,

CSE 432: Thanks for the memory leaks, Pushme-Pullyu, and Command Command Structure Diagram Command role encapsulates a function as an object Invoker calls command, command calls receiver –Same class may play one or several of these roles > action(args) execute ( ) state_ * > stereotype gives role name

CSE 432: Thanks for the memory leaks, Pushme-Pullyu, and Command Command Interaction Diagram Client creates command, gives to invoker Invoker executes command when appropriate –Command then invokes action on the receiver aCommandanInvokeraClientaReceiver / construct store executeaction time

CSE 432: Thanks for the memory leaks, Pushme-Pullyu, and Command Example Use of Command: Undo Client performs action, undo stack remembers Undo call executes top command on stack Command restores previous state (LIFO) UndoCommandUndoStackClientSystem / construct store executerestore time action remember undo

CSE 432: Thanks for the memory leaks, Pushme-Pullyu, and Command A Couple Variations on the Undo Example Some actions have closed form inverses –Object creation/destruction, some arithmetic, etc. –Natural to implement undo as in previous slide –Simply store command for inverse action in stack Some actions do not have closed form inverses –Randomization (shuffling), arbitrary state changes –Further constrains the space of possible designs –New design force: offer undo commands without requiring an action have an inverse action –Solution: use memento to remember prior state –Why not implement undo this way always?