Software Engineering and Architecture

Slides:



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

Feb. 23, 2004CS WPI1 CS 509 Design of Software Systems Lecture #5 Monday, Feb. 23, 2004.
May-June 2001 ISISTAN Research Institute – Tandil, Argentina Software Design Methodologies: UML in Action Dr. Mohamed Fayad, J.D. Edwards Professor Department.
© M.E. Fayad SJSU -- CmpE Analysis Heuristics Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering San.
Reuse Activities Selecting Design Patterns and Components
Copyright © 2002, Systems and Computer Engineering, Carleton University Intro.ppt * Object-Oriented Software Development Unit 1 Course.
Design Patterns.
Software Design Refinement Using Design Patterns Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
Case Studies on Design Patterns Design Refinements Examples.
Chapter 18 Object Database Management Systems. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Motivation for object.
The Factory Patterns SE-2811 Dr. Mark L. Hornick 1.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Introduction to Design. What is Design? 2 minutes Pairs.
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:
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
HotCiv Project Starting up!. Henrik Bærbak Christensen2 HotCiv = Agile development Iterations of –product development –learning increments.
Deriving State…...and an example of combining behaviour.
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Multi Dimensional Variance: How to make ultra flexible software!
Mandatory 1 / AlphaCiv … Traps to be aware of …. Warn or not? I once asked Kent Beck the following –I have a lot of students in a course in design patterns.
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.
Mandatory 1 / AlphaCiv … a few comments…. Overall: Generally – good work – good effort Seems you are generally doing TDD Minor hick-ups –”My own way is.
CS, AUHenrik Bærbak Christensen1 Compositional Design Principles The “GoF” principles Or Principles of Flexible Design.
Duke CPS Programming Heuristics l Identify the aspects of your application that vary and separate them from what stays the same ä Take what varies.
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.
Csci 490 / Engr 596 Special Topics / Special Projects Software Design and Scala Programming Spring Semester 2010 Lecture Notes.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Instantiating the MiniDraw Framework
Introducing a Framework ... and a few patterns
Design Patterns: MORE Examples
Inheritance ITI1121 Nour El Kadri.
Low Budget Productions, LLC
HotCiv Project Starting up!.
Mandatory 1 / AlphaCiv … Traps to be aware of ….
Compositional Design Principles
Week 4 Object-Oriented Programming (1): Inheritance
Software Design Lecture : 14.
SAMANVITHA RAMAYANAM 18TH FEBRUARY 2010 CPE 691
CS 350 – Software Design Principles and Strategies – Chapter 14
Objects First with Java A Practical Introduction using BlueJ
Structural Patterns: Adapter and Bridge
CMPE 135 Object-Oriented Analysis and Design March 21 Class Meeting
Objects First with Java A Practical Introduction using BlueJ
Component Based Software Engineering (CBSE)
Object-Oriented Analysis & Design
Object-Oriented PHP (1)
Advanced Object-Oriented Analysis & Design
Chapter 8, Design Patterns Introduction
Component Based & Software Reuse
5. Strategy, Singleton Patterns
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
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
Presentation transcript:

Software Engineering and Architecture Mandatory Hints

I would have made it differently today… Correction to the book! I would have made it differently today…

Include central methods Present book: I do not show the central method in the strategy  calculateTime() I should have. Do it in your hand-ins! AU CS Henrik Bærbak Christensen

Delegation that does not help On the contrary…

Henrik Bærbak Christensen Inheritance by Hand Maintain 1-1 mapping between a Unit and a ActionStrategy So at (6,5) there must be a Settler; and at (6,5) therefore a SettlerActionStrategy AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen Inheritance by Hand Then to perform an action What is this? It is not strategy! It is an object where we maintain a relation to one of its methods by hand. It would be easier to just have the method in the Unit, right, and then use subclassing to determine its actual implementation. So this is ‘inheritance’ but hand coded! Fragile, tedious, low maintainability, an all the way inproper solution… AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen Inheritance by Hand Another example: An AlphaGame inside a BetaGame endOfTurn() { alphaCiv.endOfTurn(); } moveUnit(f,t) { return alphaCiv.moveUnit(f,t); } getAge() { [beta civ code here] } This is not Strategy! It is recoding inheritance by hand!!! You just hardcode ‘super’ to be ‘alphaCiv’ CS@AU Henrik Bærbak Christensen

Multi Roled Abstractions Big Ball of Mud Strategy Blob Strategy Multi-dimensional Variance

Henrik Bærbak Christensen Consider… One Strategy to Rule Them All! What is the problem? AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen The Problem ZetaCiv I want to WinnerStrategy to be a combination of those of BetaCiv and EpsilonCiv ZetaCivVariantStrategy extends BetaCivVariant and EpsilonCiv Actually, it is the main discussion in the State Chapter in FRS and the State Pattern lecture  AU CS Henrik Bærbak Christensen

Inner and Outer Encapsulation

Henrik Bærbak Christensen How do I? Switch from channel TV2 to DR on my Samsung TV set? A) Push the Button ‘3’ on the TV’s remote control interface? B) Call Samsung to tell them to send a man to re-solder the wire inside the TV set? Many of you accidentally use method B CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Example What happens when I want a WorldWar II HotCiv? I have to call you guys to resolder the wires! AU CS Henrik Bærbak Christensen

Henrik Bærbak Christensen Frameworks What is the process in the mandatory exercises? To use TDD and compositional design to transform an AlphaCiv application into a HotCiv framework Frameworks are Reusable software designs and implementations Must be reconfigurable from the outside Just like a TV set Example Java Swing Graphical Framework for Java I did not call Oracle to make them rewrite their constructor in order to introduce the special graphical component I wrote! CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Open/Closed Open for Extension (I can adapt the framework) Closed for Modificaction (But I cannot rewrite the code) Change by addition, not by modification So public GameImpl(String whichVariant) { If (whichVariant.equals(”Alpha”)) { ageStrategy = new AlphaAgeStrategy() Is wrong! I have to open the TV to solder the wires inside  CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen So… Keep GameImpl, UnitImpl, CityImpl, … closed for modification! Allow adapting HotCiv to a WWII scenario by addition I can code a WorldLayoutStrategy that produce a europe map Etc. And provide my strategies in the constructor of your GameImpl And it will do the right thing… CS@AU Henrik Bærbak Christensen

Who knows how old the game is? Storing State Who knows how old the game is?

State in Strategies? Game age state can be stored in Keep track of how many rounds have been played AgeStrategy: Ok, some suggested keeping state (age) only here… Strategy pattern is about algorithms Algorithms compute stuff, they do not know stuff… I may change the algorithm Change the strategy at runtime Cohesion again! Keep the state in the object where is belongs AU CS Henrik Bærbak Christensen

Unit and Integration Testing

Unit Testing Preferred ActionStrategy is difficult to test with your present knowledge, so use integration testing for that. (Test spies will help us out later…) AU CS Henrik Bærbak Christensen

Keeping Game encapsulated Why not program to interface internally? Bindings in Game Keeping Game encapsulated Why not program to interface internally?

Read-Only Interfaces The central statement is: Only the Game instance is allowed to modify internal game state… How do we ensure that there are no other mutator methods visible to, say, the GUI programmers than those in Game interface?

Morale: Only Game has mutator methods! Design Issues Read-only interfaces for City, Tile, Unit – Why? Otherwise two ways of changing state in a game Through Game which will enforce consistency Through City which will NOT enforce consistency If there are two ways Bjarne will use the wrong one! ‘getCityAt(p).setTreasuryTo(10000);’ Morale: Only Game has mutator methods! But how to change state? Only CityImpl has mutators; GameImpl only use CityImpl? ModifiableCity interface; GameImpl only use that GameImpl takes on all responsibility?

Sketches Knowing the Implementation type in Game Liabilities Fails if we must allow external clients to configure our Game with new City implementations  Dependency injection and stuff... We have high coupling between Game and CityImpl ()

Sketches Using an ”modifiable interface” that extends read-only intf. Now the Game can get any class that implements ModifiableCity injected and handle it... ModifiableCity

My opinion It is fully OK for GameImpl to Operate through CityImpl, UnitImpl, etc. Do a cast ala (CityImpl) this.getCityAt(p) Why: Because we are developing the internal production code These are meant to be long lived (make’em rather dumb PODOs!) The GUI guys only use Game interface The Domain guys (= us) use the internals

My opinion ”More beautiful” to use a ‘ModifiableCity’ interface? Simplicity: maximize work not done We do not need it at the moment It introduces more complexity If need arise, easy to refactor CityImpl -> ModifiableCity