Behavioral Patters

Total Page:16

File Type:pdf, Size:1020Kb

Behavioral Patters 11. Behavioral Pattern Venkat Subramaniam BDP-1 Behavioral Patters • Concerned with algorithms & assignment of responsibilities • Patterns of Communication between Objects Venkat Subramaniam BDP-2 Chain of Responsibility Pattern —Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it“ Venkat Subramaniam BDP-3 Example that would benefit from Chain Of Responsibility Pattern • Various types of Controls are used in an application. Controls handle certain events while they do not handle others. Each control may be invoked from other controls. An event not handled by a control must be passed on to its parent control. Venkat Subramaniam BDP-4 Example using Chain of Responsibility Pattern Client Event Handler handleEvent() Control1 Control2 handleEvent() handleEvent() Venkat Subramaniam BDP-5 When to use Chain Of Responsibility Pattern • More than one object may handle a request, and the handler isn‘t known ahead of time. • One of several objects may be the intended receiver • Set of objects that handle request is dynamic Venkat Subramaniam BDP-6 Consequences of using Chain Of Responsibility • Reduced Coupling • Flexibility in assigning responsibilities œ Distributes responsibilities among objects • Receipt isn‘t guaranteed Venkat Subramaniam BDP-7 Chain Of Responsibility Vs. Other Patterns • Often used with Composite œ Parent acts as Successor Venkat Subramaniam BDP-8 Iterator Pattern —Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation“ Venkat Subramaniam BDP-9 Example that would benefit from Iterator • Several types of collections are available œ List, Set, Queue, Vector • We are interested in performing some operation on each element in a collection, without regard to which collection we use Venkat Subramaniam BDP-10 Example using Iterator Pattern Aggregate Client Iterator CreateIterator() First() Next() IsDone() CurrentItem() ConcreateAggregate ConcreteIterator Venkat Subramaniam BDP-11 When to use Iterator Pattern • Elements of an Aggregate needs to be accessed without exposing internal representation of the aggregate • multiple traversals on an aggregate • uniform traversal on different aggregates Venkat Subramaniam BDP-12 Consequences of using Iterator • Supports variations in the traversal • Simplifies interface of Aggregates • More than one traversal may be acting on the aggregate at any time Venkat Subramaniam BDP-13 Iterator Vs. Other Patterns • Often applied to recursive structures such as Composite • Factory method instantiate appropriate Iterator • Memento used in conjunction with Iterator. Iterator stores memento internally to capture the state Venkat Subramaniam BDP-14 Mediator Pattern — efine an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently“ Venkat Subramaniam BDP-15 Example that would benefit from Mediator • An application is used to design Wheels • The diameter of the rim is restricted by the Hub diameter • The tire diameter is dependent on the rim • The spokes length needs to be altered if hub diameter or rim diameter is changed Venkat Subramaniam BDP-16 Example using Mediator Pattern Hub Rim Mediator Spoke Tire Venkat Subramaniam BDP-17 When to use Mediator Pattern • Set of objects communicate in complex well defined way • You want to reduce interdependency between objects • Reusing object is difficult if it refers to several other objects • Behavior distributed between several classes must be customizable without lot of sub- classing Venkat Subramaniam BDP-18 Consequences of using Mediator • Localizes behavior that may otherwise be distributed among several objects • Subclass mediator to change this behavior • Decouples Colleagues • Replaces many-to-many interactions with one-to-many interaction œ Easy to maintain, extend and understand Venkat Subramaniam BDP-19 Mediator Vs. Other Patterns • Facade œ In Mediator, Colleague objects know Mediator œ In Facade subsystem classes do not see Facade • Colleagues may communicate with Mediator using Observer Venkat Subramaniam BDP-20 Memento Pattern —Without violating encapsulation, capture and externalize an object‘s internal state so that the object can be restored to its state later“ Venkat Subramaniam BDP-21 Example that would benefit from Memento • You want to let the user modify an object • However the user may cancel the modification • You want to store the internal state of a complex object to restore it later Venkat Subramaniam BDP-22 Example using Memento Pattern Originator Memento Caretaker state state SetMemento(Memento m) GetState() CreateMemento() SetState() return new Memento(state) state = m->GetState() Venkat Subramaniam BDP-23 When to use Memento Pattern • A snapshot of an object‘s state must be saved to restore later • you do not want to expose the implementation details of the internal state of an object, breaking its encapsulation Venkat Subramaniam BDP-24 Consequences of using Memento • Simplifies the Originator • Preserves encapsulation boundaries • May be expensive • Defining narrow and wide interfaces œ How to ensure only originator accesses memento‘s state • Caretaker is responsible for deleting memento œ Lightweight caretakers may be burdened with large mementos Venkat Subramaniam BDP-25 Memento Vs. Other Patterns • Command œ May use mementos to maintain state for undo operations • Iterator œ Mementos can be used for storing internal state of iterators Venkat Subramaniam BDP-26 Observer Pattern — efine a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically“ Venkat Subramaniam BDP-27 Example that would benefit from Observer • You have several views of a document œ Graph View œ TabularView œ ChartView • The user may change the data of a document from any of the visible views • You want to keep all the views synched with the change to the document‘s data Venkat Subramaniam BDP-28 Example using Observer Pattern Observers Abstract Document View Attach(View observerView) Update Detach(View observerView) Notify() GraphView TabularView ChartView YourDocument Venkat Subramaniam BDP-29 When to use Observer Pattern • When an abstraction has two aspects one dependent on the other. Encapsulating these aspects in separate objects lets you vary and reuse them independently • Change to one object requires change to others œ don‘t know how many objects need change • Object is able to notify other objects without knowing who these objects are - don‘t want tight coupling Venkat Subramaniam BDP-30 Consequences of using Observer • Abstract the coupling between observers and subject • Support for broadcast communication • Unexpected updates œ May be expensive and untimely • May abstract a hint on the subject change Venkat Subramaniam BDP-31 Observer Vs. Other Patterns • Mediator may be used to mediate between several subjects and observers Venkat Subramaniam BDP-32 State Pattern —Allow an object to alter its behavior when its internal state changes. The object will appear to change its state“ Venkat Subramaniam BDP-33 Example that would benefit from State Pattern • A train may run in forward or reverse mode. • When running in forward mode the head lights on the front engine are on and the tail lights on the back engine are on. • When running in reverse mode the reverse is true. • Acceleration will move the engine forward or backward depending on the mode Venkat Subramaniam BDP-34 Example using State Pattern currentMode Train TrainDirection turnHeadLights() turnTailLights() ForwardMode ReverseMode accelerate() turnHeadLights() turnHeadLights() turnTailLights() turnTailLights() accelerate() accelerate() Venkat Subramaniam BDP-35 When to use State Pattern • An object‘s behavior depends on its state and must change its behavior at run-time depending on that state • Operations have large conditional statements that depend on the state. State pattern puts each branch of the conditional in a separate class. Venkat Subramaniam BDP-36 Consequences of using State • Localizes state-specific behavior and partitions behavior for different states • Makes state transitions explicit • State objects can be shared Venkat Subramaniam BDP-37 State Vs. Other Patterns • Flyweight pattern may be used to share state which may be singletons. Venkat Subramaniam BDP-38 Strategy Pattern — efine a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it“ Venkat Subramaniam BDP-39 Example that would benefit from Strategy Pattern • A property may be computed using one of several methods/algorithms • Each method comes with its own features and trade-offs œ For instance, a method may converge towards a result at a faster rate but may use more memory œ Another method may not require as much memory • Design your class such that the client may use any applicable method to compute property Venkat Subramaniam BDP-40 Example using Strategy Pattern methodToUse Property MethodForProperty Compute() compute() Method1 Method1 compute() compute() Venkat Subramaniam BDP-41 When to use Strategy Pattern • Many related classes differ only in their behavior. Strategy provides a way to configure a class with one of many behaviors • Use different variants of an algorithm
Recommended publications
  • Behavioral Patterns
    Behavioral Patterns 101 What are Behavioral Patterns ! " Describe algorithms, assignment of responsibility, and interactions between objects (behavioral relationships) ! " Behavioral class patterns use inheritence to distribute behavior ! " Behavioral object patterns use composition ! " General example: ! " Model-view-controller in UI application ! " Iterating over a collection of objects ! " Comparable interface in Java !" 2003 - 2007 DevelopIntelligence List of Structural Patterns ! " Class scope pattern: ! " Interpreter ! " Template Method ! " Object scope patterns: ! " Chain of Responsibility ! " Command ! " Iterator ! " Mediator ! " Memento ! " Observer ! " State ! " Strategy ! " Visitor !" 2003 - 2007 DevelopIntelligence CoR Pattern Description ! " Intent: Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it. ! " AKA: Handle/Body ! " Motivation: User Interfaces function as a result of user interactions, known as events. Events can be handled by a component, a container, or the operating system. In the end, the event handling should be decoupled from the component. ! " Applicability: ! " more than one object may handle a request, and the handler isn't known a priori. ! " Want to issue a request to one of several objects without specifying the receiver !" 2003 - 2007 DevelopIntelligence CoR Real World Example ! " The Chain of Responsibility pattern avoids coupling the sender of a request to the receiver, by giving more than one object a chance to handle the request. ! " Mechanical coin sorting banks use the Chain of Responsibility. Rather than having a separate slot for each coin denomination coupled with receptacle for the denomination, a single slot is used. When the coin is dropped, the coin is routed to the appropriate receptacle by the mechanical mechanisms within the bank.
    [Show full text]
  • Scala by Example (2009)
    Scala By Example DRAFT January 13, 2009 Martin Odersky PROGRAMMING METHODS LABORATORY EPFL SWITZERLAND Contents 1 Introduction1 2 A First Example3 3 Programming with Actors and Messages7 4 Expressions and Simple Functions 11 4.1 Expressions And Simple Functions...................... 11 4.2 Parameters.................................... 12 4.3 Conditional Expressions............................ 15 4.4 Example: Square Roots by Newton’s Method................ 15 4.5 Nested Functions................................ 16 4.6 Tail Recursion.................................. 18 5 First-Class Functions 21 5.1 Anonymous Functions............................. 22 5.2 Currying..................................... 23 5.3 Example: Finding Fixed Points of Functions................ 25 5.4 Summary..................................... 28 5.5 Language Elements Seen So Far....................... 28 6 Classes and Objects 31 7 Case Classes and Pattern Matching 43 7.1 Case Classes and Case Objects........................ 46 7.2 Pattern Matching................................ 47 8 Generic Types and Methods 51 8.1 Type Parameter Bounds............................ 53 8.2 Variance Annotations.............................. 56 iv CONTENTS 8.3 Lower Bounds.................................. 58 8.4 Least Types.................................... 58 8.5 Tuples....................................... 60 8.6 Functions.................................... 61 9 Lists 63 9.1 Using Lists.................................... 63 9.2 Definition of class List I: First Order Methods..............
    [Show full text]
  • HEDGEHOG: Automatic Verification of Design Patterns in Java
    HEDGEHOG: Automatic Verification of Design Patterns in Java Alex Blewitt I V N E R U S E I T H Y T O H F G E R D I N B U Doctor of Philosophy School of Informatics University of Edinburgh 2006 Abstract Design patterns are widely used by designers and developers for building complex systems in object-oriented programming languages such as Java. However, systems evolve over time, increasing the chance that the pattern in its original form will be broken. To verify that a design pattern has not been broken involves specifying the original intent of the design pattern. Whilst informal descriptions of patterns exist, no formal specifications are available due to differences in implementations between programming languages. This thesis shows that many patterns (implemented in Java) can be verified automatically. Patterns are defined in terms of variants, mini-patterns, and artefacts in a pattern description language called SPINE. These specifications are then processed by HEDGEHOG, an automated proof tool that attempts to prove that Java source code meets these specifications. iii Acknowledgements I am indebted to Alan Bundy who has given me the freedom to work on this thesis whilst at the same time guiding me towards the final production and presentation of these results. I not would have been able to achieve this without Alan’s support through a sometimes difficult, but always busy part of my life. This project, and especially the production of this thesis, would not have been possible without the care and attention that Alan provided. Ian Stark has provided invaluable feedback on all aspects of this thesis, from the low-level technical intricacies of Java’s design patterns through to the high-level structure of the thesis as a whole.
    [Show full text]
  • Design Pattern Implementation in Java and Aspectj
    Design Pattern Implementation in Java and AspectJ Jan Hannemann Gregor Kiczales University of British Columbia University of British Columbia 201-2366 Main Mall 201-2366 Main Mall Vancouver B.C. V6T 1Z4 Vancouver B.C. V6T 1Z4 jan [at] cs.ubc.ca gregor [at] cs.ubc.ca ABSTRACT successor in the chain. The event handling mechanism crosscuts the Handlers. AspectJ implementations of the GoF design patterns show modularity improvements in 17 of 23 cases. These improvements When the GoF patterns were first identified, the sample are manifested in terms of better code locality, reusability, implementations were geared to the current state of the art in composability, and (un)pluggability. object-oriented languages. Other work [19, 22] has shown that implementation language affects pattern implementation, so it seems The degree of improvement in implementation modularity varies, natural to explore the effect of aspect-oriented programming with the greatest improvement coming when the pattern solution techniques [11] on the implementation of the GoF patterns. structure involves crosscutting of some form, including one object As an initial experiment we chose to develop and compare Java playing multiple roles, many objects playing one role, or an object [27] and AspectJ [25] implementations of the 23 GoF patterns. playing roles in multiple pattern instances. AspectJ is a seamless aspect-oriented extension to Java, which means that programming in AspectJ is effectively programming in Categories and Subject Descriptors Java plus aspects. D.2.11 [Software Engineering]: Software Architectures – By focusing on the GoF patterns, we are keeping the purpose, patterns, information hiding, and languages; D.3.3 intent, and applicability of 23 well-known patterns, and only allowing [Programming Languages]: Language Constructs and Features – the solution structure and solution implementation to change.
    [Show full text]
  • Resilience Design Patterns a Structured Approach to Resilience at Extreme Scale - Version 1.0
    ORNL/TM-2016/687 Resilience Design Patterns A Structured Approach to Resilience at Extreme Scale - version 1.0 Saurabh Hukerikar Christian Engelmann Approved for public release. October 2016 Distribution is unlimited. DOCUMENT AVAILABILITY Reports produced after January 1, 1996, are generally available free via US Department of Energy (DOE) SciTech Connect. Website: http://www.osti.gov/scitech/ Reports produced before January 1, 1996, may be purchased by members of the public from the following source: National Technical Information Service 5285 Port Royal Road Springfield, VA 22161 Telephone: 703-605-6000 (1-800-553-6847) TDD: 703-487-4639 Fax: 703-605-6900 E-mail: [email protected] Website: http://classic.ntis.gov/ Reports are available to DOE employees, DOE contractors, Energy Technology Data Ex- change representatives, and International Nuclear Information System representatives from the following source: Office of Scientific and Technical Information PO Box 62 Oak Ridge, TN 37831 Telephone: 865-576-8401 Fax: 865-576-5728 E-mail: [email protected] Website: http://www.osti.gov/contact.html This report was prepared as an account of work sponsored by an agency of the United States Government. Neither the United States Government nor any agency thereof, nor any of their employees, makes any warranty, express or implied, or assumes any legal lia- bility or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process disclosed, or rep- resents that its use would not infringe privately owned rights. Refer- ence herein to any specific commercial product, process, or service by trade name, trademark, manufacturer, or otherwise, does not nec- essarily constitute or imply its endorsement, recommendation, or fa- voring by the United States Government or any agency thereof.
    [Show full text]
  • A Pattern Language for Designing Application-Level Communication Protocols and the Improvement of Computer Science Education Through Cloud Computing
    Utah State University DigitalCommons@USU All Graduate Theses and Dissertations Graduate Studies 5-2017 A Pattern Language for Designing Application-Level Communication Protocols and the Improvement of Computer Science Education through Cloud Computing Jorge Edison Lascano Utah State University Follow this and additional works at: https://digitalcommons.usu.edu/etd Part of the Computer Sciences Commons Recommended Citation Lascano, Jorge Edison, "A Pattern Language for Designing Application-Level Communication Protocols and the Improvement of Computer Science Education through Cloud Computing" (2017). All Graduate Theses and Dissertations. 6547. https://digitalcommons.usu.edu/etd/6547 This Dissertation is brought to you for free and open access by the Graduate Studies at DigitalCommons@USU. It has been accepted for inclusion in All Graduate Theses and Dissertations by an authorized administrator of DigitalCommons@USU. For more information, please contact [email protected]. A PATTERN LANGUAGE FOR DESIGNING APPLICATION-LEVEL COMMUNICATION PROTOCOLS AND THE IMPROVEMENT OF COMPUTER SCIENCE EDUCATION THROUGH CLOUD COMPUTING by Jorge Edison Lascano A dissertation submitted in partial fulfillment of the requirements for the degree of DOCTOR OF PHILOSOPHY in Computer Science Approved: ______________________ ____________________ Stephen W. Clyde, Ph.D. Curtis Dyreson, Ph.D. Major Professor Committee Member ______________________ ____________________ Haitao Wang, Ph.D. Young-Woo Kwon, Ph.D. Committee Member Committee Member ______________________ ____________________ Luis Gordillo, Ph.D. Mark R. McLellan, Ph.D. Committee Member Vice President for Research and Dean of the School of Graduate Studies UTAH STATE UNIVERSITY Logan, Utah 2017 ii Copyright © Jorge Edison Lascano 2017 All Rights Reserved iii ABSTRACT A Pattern Language for Designing Application-Level Communication Protocols and the Improvement of Computer Science Education through Cloud Computing by Jorge Edison Lascano, Doctor of Philosophy Utah State University, 2017 Major Professor: Stephen W.
    [Show full text]
  • Java Design Patterns I
    Java Design Patterns i Java Design Patterns Java Design Patterns ii Contents 1 Introduction to Design Patterns 1 1.1 Introduction......................................................1 1.2 What are Design Patterns...............................................1 1.3 Why use them.....................................................2 1.4 How to select and use one...............................................2 1.5 Categorization of patterns...............................................3 1.5.1 Creational patterns..............................................3 1.5.2 Structural patterns..............................................3 1.5.3 Behavior patterns...............................................3 2 Adapter Design Pattern 5 2.1 Adapter Pattern....................................................5 2.2 An Adapter to rescue.................................................6 2.3 Solution to the problem................................................7 2.4 Class Adapter..................................................... 11 2.5 When to use Adapter Pattern............................................. 12 2.6 Download the Source Code.............................................. 12 3 Facade Design Pattern 13 3.1 Introduction...................................................... 13 3.2 What is the Facade Pattern.............................................. 13 3.3 Solution to the problem................................................ 14 3.4 Use of the Facade Pattern............................................... 16 3.5 Download the Source Code.............................................
    [Show full text]
  • Design Patterns Mock Test
    DDEESSIIGGNN PPAATTTTEERRNNSS MMOOCCKK TTEESSTT http://www.tutorialspoint.com Copyright © tutorialspoint.com This section presents you various set of Mock Tests related to Design Patterns Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself. DDEESSIIGGNN PPAATTTTEERRNNSS MMOOCCKK TTEESSTT IIII Q 1 - Which of the following describes the Composite pattern correctly? A - This pattern builds a complex object using simple objects and using a step by step approach. B - This pattern is used where we need to treat a group of objects in similar way as a single object. C - This pattern hides the complexities of the system and provides an interface to the client using which the client can access the system. D - This pattern is primarily used to reduce the number of objects created and to decrease memory footprint and increase performance. Q 2 - Which of the following describes the Decorator pattern correctly? A - This pattern allows a user to add new functionality to an existing object without altering its structure. B - This pattern is used where we need to treat a group of objects in similar way as a single object. C - This pattern hides the complexities of the system and provides an interface to the client using which the client can access the system. D - This pattern is primarily used to reduce the number of objects created and to decrease memory footprint and increase performance. Q 3 - Which of the following describes the Facade pattern correctly? A - This pattern allows a user to add new functionality to an existing object without altering its structure.
    [Show full text]
  • Persistent State Pattern
    Persistent State Pattern ANDRÉ V. SAÚDE, Federal University of Lavras, Department of Computer Science RICARDO A. S. S. VICTÓRIO, Mitah Technologies Inc. GABRIEL C. A. COUTINHO, Mitah Technologies Inc. Finite State Machines (FSM) provide a powerful way to describe dynamic behavior of systems and components. Implementations of FSM in Object-Oriented (OO) languages have been widely studied since the classical State Pattern has been introduced. Various design patterns were derived from the State Pattern, but all of the focus on object’s behavior. This paper describes the Persistent State Pattern, an exten- sion to the State Pattern for persistent data. The Persistent State Pattern integrates transaction management with classical and enterprise design patterns. It can be used with OO databases and relational databases, and it can also be incorporated by an object-relation mapping framework. We show how the Persistent State Pattern may be useful for model or event driven development. Categories and Subject Descriptors: D.2.2 [Software Engineering]: Design Tools and Techniques—Object-oriented design methods; D.2.10 [Design] Methodologies; H.2.8 [Database Management]: Database Administration—Security, integrity, and protection General Terms: Design Additional Key Words and Phrases: Persistent states, state machine, design patterns ACM Reference Format: Saúde, A. V., Victório, R. A. S. S. and Coutinho, G. C. A. 2010. Persistent State Pattern. Proc. 17th Conference on Pattern Languages of Programs (PLoP), (October 2010), 16 pages. 1. INTRODUCTION Finite State Machines (FSM) provide a powerful tool to describe dynamic behavior of systems and components. There are several implementations of FSM in Object-Oriented (OO) languages.
    [Show full text]
  • Non-Software Examples of Software Design Patterns Автор: Michael Duell
    Non-Software Examples of Software Design Patterns Автор: Michael Duell. Хорошая, хоть и старая (97 год) статья в которой приведены примеры применения паттернов в вещах, которые не имеют отношения к разработке. Такой подход отлично иллюстрирует паттерны и делает их более доступными для понимания. Например отлично показан паттерн Фасад: интерфейсы офисных устройств можно сильно упростить с помощью секретарши. Или например паттерн Бридж, который показан на примере выключателя которым можно управлять лампочкой, вентилятором или любым другим прибором. Non-Software Examples of Software Design Patterns by Michael Duell Abstract Software design patterns have roots in the architectural patterns of Christopher Alexander, and in the object movement. According to Alexander, patterns repeat themselves, since they are a generic solution to a given system of forces. The object movement looks to the real world for insights into modeling software relationships. With these dual roots, it seems reasonable that software design patterns should be repeated in real world objects. This paper presents a real world, non software instance of each design pattern from the book, Design Patterns - Elements of Reusable Object-Oriented Software [13]. The paper also discusses the implications of non-software examples on the communicative power of a pattern language, and on design pattern training. 1. Introduction Within the software industry, a growing community of patterns proponents exists. The roots of the patterns movement are found in the writings of architect Christopher Alexander, who describes a pattern as a generic solution to a given system of forces in the world [1]. Alexander's patterns can be observed in everyday structures. Each pattern in A Pattern Language[2] includes a picture of an archetypal example of the pattern.
    [Show full text]
  • A Pattern Language of Statecharts
    A Pattern Language of Statecharts Sherif M. Yacoub; Hany H. Ammar Computer Science and Electrical Engineering Department West Virginia University, Morgantown West Virginia, WV26506 INTRODUCTION Finite state machines and their extension to statecharts are widely used in reactive systems. David Harel [Harel87] has introduced statecharts as an extension of finite state machines to describe the complex behavior of an entity. The formalized concepts of statecharts and their specifications have been used in many applications. Here, we show how to solve recurring design problems in implementing statechart specification of an entity in an object-oriented application. The statecharts' patterns represent solutions to frequent design problems that are commonly thought of by system designers, which include how to deploy hierarchy, orthogonality, and broadcasting in a statechart's object oriented design. Since statecharts are frequently applicable to software applications, thus it is helpful for the system designer to directly exercise the statechart pattern language in his application design. In the next section, a quick background of statechart is presented, then a pattern map summarizes the statechart patterns and their relation to finite state machine patterns. The rest of the sections describe the patterns themselves. BACKGROUND David Harel [Harel87,Harel88] introduced statecharts to extend finite state machine for complex behavior and to describe a visual formalism. Objectcharts were then presented by Derek Coleman et.al.[CHB92] as an extension to describe how to use statecharts in object-oriented environment to describe the lifecycle of an object. Statecharts were used by Bran Selic [Selic98] as an implementation mechanism for Recursive Control. Alternatively, we perceive that statecharts are frequently used as a behavior description technique and using an object-oriented design of statechart provides flexibility at the design level and facilitates the design maintainability.
    [Show full text]
  • Design Patterns
    Team 302 Design Patterns Design Patterns Solutions to software design problems you find again and again in real-world application development Patterns are about reusable designs and interactions of objects. Contains “Best Practices” Gang of Four (GoF) released the first ones Team302 – Design Patterns Design Patterns Gang of Four . Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides . 23 Design Patterns released in 1994 Book o Program for interface vs. implementation o Composition vs. Inheritance . More flexible . “Has a” is better than “Is a” . Three categories of Patterns o Creational o Structural o Behavioral Team302 – Design Patterns Design Patterns - References http://gameprogrammingpatterns.com/contents.html http://www.dofactory.com/net/design-patterns http://www.oodesign.com/ https://sourcemaking.com/design_patterns Team302 – Design Patterns Design Patterns - Creational Creates objects while hiding the creation logic Patterns: ○ Abstract Factory ○ Builder ○ Factory ○ Prototype ○ Singleton Team302 – Design Patterns Factory Pattern Interface for creating object Factory calls creator Interaction with the interface of created object Example Team302 – Design Patterns Singleton Pattern One instance of the class Careful not to abuse (limits multithreading capability) Example Team302 – Design Patterns Design Patterns - Structural Related to class and object composition Inheritance is to compose interface Define ways to compose objects into new functionality Patterns: ○ Adapter ○ Bridge ○ Composite ○ Decorator
    [Show full text]