design patterns refactoring
play

Design Patterns & Refactoring Comparison of the Behavioral - PowerPoint PPT Presentation

Design Patterns & Refactoring Comparison of the Behavioral Patterns Oliver Haase HTWG Konstanz Oliver Haase (HTWG Konstanz) Design Patterns & Refactoring 1 / 7 Encapsulation of the Variation Many behavioral patterns encapsulate the


  1. Design Patterns & Refactoring Comparison of the Behavioral Patterns Oliver Haase HTWG Konstanz Oliver Haase (HTWG Konstanz) Design Patterns & Refactoring 1 / 7

  2. Encapsulation of the Variation Many behavioral patterns encapsulate the varying concept, clients are loosely coupled to the encapsulated concept: behavioral pattern encapsulated concept strategy algorithm state state dependend behavior broker protocol between objects iterator access to and traversal of collections Without encapsulation, varying concept would be integrated into client object Oliver Haase (HTWG Konstanz) Design Patterns & Refactoring 2 / 7

  3. Objects as Arguments Some behavioral patterns define objects that are always used as arguments, e.g. visitor pattern → Visitor always used as argument to accept -call of a Node . Some patterns define object that is passed around as magic token without the clients’ knowledge of its content ( Command object, Memento object). Oliver Haase (HTWG Konstanz) Design Patterns & Refactoring 3 / 7

  4. Encapsulation or Distribution of Communication Observer Pattern: Communication is distributed across subjects (observables) and observers Responsibility to preserve consistency is shared. Communication flows at run-time are hard to understand Oliver Haase (HTWG Konstanz) Design Patterns & Refactoring 4 / 7

  5. Encapsulation or Distribution of Communication Broker Pattern: Communication is centralized in broker (mediator) object Broker is responsible to preserve consistency Broker is single point of failure and scalability bottle-neck Communication flows at run-time are easier to understand Oliver Haase (HTWG Konstanz) Design Patterns & Refactoring 5 / 7

  6. Decoupling of Sender and Receiver An object that uses another object gets dependent on it. The following patterns follow different approaches to minimize this coupling: Command : Sender uses Command object through a small, predefined interface, .i.e. execute operation. Command object uses the receiver’s specific, possibly complex interface. Observer : Subjects notify observers through a simply notify operation, decoupling subjects from observers. Oliver Haase (HTWG Konstanz) Design Patterns & Refactoring 6 / 7

  7. Decoupling of Sender and Receiver Broker : Sender uses Broker object to communicate with receiver. This decouples senders from receivers, but couples them to broker. Chain of Responsibility : Client is decoupled from receivers through their internal chaining of the request. Oliver Haase (HTWG Konstanz) Design Patterns & Refactoring 7 / 7

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend