Software Engineering and Architecture

Slides:



Advertisements
Similar presentations
The Bridge Pattern.. Intent Decouple an abstraction from its implementation so that the two can vary independently Also known as: Handle/Body.
Advertisements

Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
Marcelo Santos – OOAD-CDT309, Spring 2008, IDE-MdH 1 Object-Oriented Analysis and Design - CDT309 Period 4, Spring 2008 Design Patterns: someone has already.
Chapter 1: Introduction to Design Patterns. SimUDuck Example.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Sayed Ahmed Computer Engineering, BUET, Bangladesh Masters from the University of Manitoba, Canada
CS 350 – Software Design The Strategy Pattern – Chapter 9 Changes to software, like other things in life, often focus on the immediate concerns and ignore.
L8 - March 28, 2006copyright Thomas Pole , all rights reserved 1 Lecture 8: Software Asset Management and Text Ch. 5: Software Factories, (Review)
Unit 4 Object-Oriented Design Patterns NameStudent Number CAI XIANGHT082182A KYAW THU LINHT082238Y LI PENGFEIHT082220L NAUNG NAUNG LATTHT082195L PLATHOTTAM.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VIII Chain of Responsibility, Strategy, State.
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Henrik Bærbak Christensen1 Frameworks / Product Lines The frame for reuse.
Test Stubs... getting the world under control. TDD of State Pattern To implement GammaTown requirements I CS, AUHenrik Bærbak Christensen2.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
Deriving State…...and an example of combining behaviour.
Multi Dimensional Variance: How to make ultra flexible software!
Applying the Principles Two Examples. Example 1 New Requirement It would be nice with a simple GUI “to see something” instead of just xUnit tests...
Refactoring and Integration Testing or Strategy, introduced reliably by TDD The power of automated tests.
MiniDraw Introducing a Framework... and a few patterns.
Mandatory 2 / Strategies Note: I publish this presentation at the week plan for week 4.
Patterns are Roles What patterns are and what not…
Software Architecture Quality Attributes. Good or Bad? Measurable criterions required...
Object- oriented Design Principles
CS, AUHenrik Bærbak Christensen1 Compositional Design Principles The “GoF” principles Or Principles of Flexible Design.
An object's behavior depends on its current state. Operations have large, multipart conditional statements that depend on the object's state.
Mandatory 3 Test Stubs State Abstract Factory. Stubs, Spies, and Fake Objects One Example Making distribution testable... Henrik Bærbak Christensen2.
Mandatory 3 Test Stubs State Abstract Factory. Do not panic! dSoftArk is about Good analyzable design not about HotCiv! Henrik Bærbak Christensen2.
Strategy in 15 minutes... derived from the principles.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Hints - Mandatory 5 Blackbox Testing Pattern Hunting.
Introducing a Framework ... and a few patterns
Design Patterns Source: “Design Patterns”, Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides And Created.
Design Patterns: MORE Examples
Software Architecture in Practice
Applying the Principles
Conception OBJET GRASP Patterns
Introduction to Design Patterns
CS 350 – Software Design The Strategy Pattern – Chapter 9
Chapter Nine The Strategy Pattern
Behavioral Design Patterns
CMPE 135: Object-Oriented Analysis and Design October 24 Class Meeting
Compositional Design Principles
Lecture 2 of Computer Science II
Phil Tayco Slide version 1.0 Created Nov. 26, 2017
Presented by Igor Ivković
Objects First with Java A Practical Introduction using BlueJ
Reusability 11/29/2018© 2006 ITT Educational Services Inc.
Software Design Lecture : 14.
Chapter 19: Interfaces and Components
DESIGN PATTERNS : Strategy Pattern
DESIGN PATTERNS : State Pattern
CS 350 – Software Design Principles and Strategies – Chapter 14
Objects First with Java A Practical Introduction using BlueJ
Strategy Design Pattern
CMPE 135 Object-Oriented Analysis and Design March 21 Class Meeting
Objects First with Java A Practical Introduction using BlueJ
Slide design: Dr. Mark L. Hornick
Presented by Igor Ivković
Object Oriented Design & Analysis
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
Presentation transcript:

Software Engineering and Architecture Multi Dimensional Variance Ultra flexible software

Goal and means to an end? Patterns: Goal in itself or just the means to an end? Patterns are interesting as means to achieve some specific quality in our software: elements of Reusable ... A key aspect is handling variance CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Variance Factoring out in roles and delegating to objects that play roles is a very strong technique to handle multiple dimensions of variance! that is – a piece of software that must handle different types of context work on both Oracle and MS database work in both debug and production environment work both with real hardware attached or simulated environment work with variations for four different customers Here all types of combinations are viable ! CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen New Requirements Alphatown county wants the display to show parking end time instead of minutes bought! CS@AU Henrik Bærbak Christensen

Combinatorial explosion! All these requirements pose a combinatorial explosion of variants  There are 3*2*2 = 12 combinations. This may be doubled if we include overriding weekend day algorithm ! CS@AU Henrik Bærbak Christensen

Restating the options

Henrik Bærbak Christensen Parametric Variance Variant handling by if (param) or #ifdef’s is well known, but the code simply bloats with conditional statements. Example: GNU C compiler has a single statement that includes 41 macro expansions !!! I wonder what that code does??? #ifdef ( MSDOS && ORACLE || MYSQL && …) #ifdef ( DEBUG ) quickly you loose control of what is going on… CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Polymorphic Variance Inheritance dies miserably facing this challenge! Just look at names! Making new variants is difficult. And code reuse is very difficult  CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Masking the problem By combining parametric and polymorphic variance you may mask the problem somewhat. I.e. handle receipt type by inheritance, and the rest by pumping the code with if’s… but … it is still an inferior way to handle multi-dimensional variance… CS@AU Henrik Bærbak Christensen

Compositional software The way forward is: Compositional software Highly configurable and flexible software!  Consider what behaviour that may vary  Express variable behaviour as a responsibility clearly defined by an interface  Delegate to object serving the responsibility to perform behaviour CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen     Encapsulate what varies The display output must exist in variants  Program to an interface <<interface>> DisplayStrategy public int calculateOutput( int minutes );  Favor object composition public int readDisplay() { return displayStrategy.calculateOutput(timeBought); } CS@AU Henrik Bærbak Christensen

Compositional software [Demo] codelab / many-to-many CS@AU Henrik Bærbak Christensen

Compositional Software [Backgammon Demo] CS@AU Henrik Bærbak Christensen

Compositional software The paystation has become a team leader, delegating jobs to his specialist workers: Note! No if’s – no bloat – easy to read code leading to fewer bugs! public int readDisplay() { return displayStrategy.calculateOutput(timeBought); } timeBought = rateStrategy.calculateTime(insertedSoFar); public Receipt buy() { Receipt recipt = factory.createReceipt( this ); resetTransaction(); return recipt; } CS@AU Henrik Bærbak Christensen

Compositional software Telling the team leader which persons will serve the roles: The factory interface CS@AU Henrik Bærbak Christensen

Compositional software Creating a parking machine: create the factory create the pay station, giving it access to the factory PayStationFactory psf = new AlphaTownFactory(); PayStation pm = new PayStationImpl( psf ); CS@AU Henrik Bærbak Christensen

Compositional software ... and a factory: class AlphaTownFactory implements PayStationFactory { public RateStrategy createRateStrategy() { return new LinearRateStrategy(); } public DisplayStrategy createDisplayStrategy() { return new EndTimeDisplayStrategy(); public Receipt createReceipt( int parkingTime ) { return new StandardReceipt(parkingTime); CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Analysis Benefits The variability points are independent we introduced new display strategy – but this did not alter any of the existing strategies ! Once the variability point has been introduced we can introduce as many new types of variations as we like – only by adding new classes any price model; new receipt types; new display output... Open-closed principle in action... public int readDisplay() { return displayStrategy.calculateOutput(timeBought); } open to extension / CS@AU Henrik Bærbak Christensen

Open/Closed principle Open for extension Closed for modification CS@AU Henrik Bærbak Christensen

Open/Closed principle Open for extension I can make my own feature additions/changes by extending the software Closed for modification But I do not rewrite any existing code Or ask Oracle, Google, NetFlix, Apache, to rewrite code to handle my extensions CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Analysis Benefits Any combination you want, we are able to “mix” Nonsense combinations can be delimited abstract factory is the place to “mix” the cocktails Code readability every aspect of the configuration is clearly defined in a single place configuration mixing in the abstract factory orchestration in the PayStation impl each variation type in its own implementing class CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Analysis Liabilities Each dimension of variability (price model, receipt type, display output, etc) is really independent – so we cannot feed information from one to the other directly  If they require information from each other Then of course we must provide the means to do so Mediator pattern, memento pattern, others Like we do in mandatory project GameImpl calls strategy with ‘this’ GameImpl calls mutators on strategy Read Finn’s paper CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Analysis Liabilities The number of classes in action  On the other hand: careful naming makes it possible to quickly identify which class to change… CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Analysis Liabilities Actually I have a combinatorial explosion of factories! I need a factory for each and every combination of delegates that I have Exercise: How can I avoid this explosion? CS@AU Henrik Bærbak Christensen

Handle multi-dimensional variance by compositional software designs ! Summary Handle multi-dimensional variance by compositional software designs ! CS@AU Henrik Bærbak Christensen