Mandatory 3 Test Stubs State Abstract Factory. Stubs, Spies, and Fake Objects One Example Making distribution testable... Henrik Bærbak Christensen2.

Slides:



Advertisements
Similar presentations
DAIMIHenrik Bærbak Christensen1 Testability Tactics How to make software testable...
Advertisements

Framework is l Reusable Code, often domain specific (GUI, Net, Web, etc) l expressed as l a set of classes and l the way objects in those classes collaborate.
Integration Testing When testing a module in isolation –Called modules need to be replaced –Tested module needs to be called A D ′ E ′ main driver module.
COP 3331 Object Oriented Analysis and Design Chapter 7 – Design by Abastraction Jean Muhammad.
1 Software Testing and Quality Assurance Lecture 12 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
Inheritance. Extending Classes It’s possible to create a class by using another as a starting point  i.e. Start with the original class then add methods,
Stéphane Ducasse«ChapterNr».1 Arthur Riel Design Heuristics from Object-Oriented Design Heuristics by Arthur Riel Read the Heuristics… –Find reasons why.
DAIMI(c) Henrik Bærbak Christensen1 JUnit A tool for test case management.
ECE 355 Design Patterns Tutorial Part 2 (based on slides by Ali Razavi) Presented by Igor Ivković
Reuse Activities Selecting Design Patterns and Components
DAIMI(c) Henrik Bærbak Christensen1 Test Doubles: Stubs, Spies, Mocks, etc.
Chapter 11: Inheritance and Polymorphism Java Programming: Program Design Including Data Structures Program Design Including Data Structures.
Introduction To System Analysis and design
COP 3003 Object-Oriented Programming - Polymorphism Dr. Janusz Zalewski, Fall 2013 Prepared by Dr Dahai Guo.
Design Patterns.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
CSC 211 Introduction to Design Patterns. Intro to the course Syllabus About the textbook – Read the introduction and Chapter 1 Good attendance is the.
1 Lesson 8: Basic Monte Carlo integration We begin the 2 nd phase of our course: Study of general mathematics of MC We begin the 2 nd phase of our course:
 How are you going to collaborate?  How are you going to divide up work?  How are you going to make sure that changes work with other people’s code?
S.Ducasse Stéphane Ducasse 1 Design Heuristics.
1 Computer Science 340 Software Design & Testing Inheritance.
Object Oriented Software Development
Lecture 12 March 16, The Scope of a Variable What if there are two variables with the same name? –A local or block-local variable can have the same.
CSE 341, S. Tanimoto Java brief review - 1 Java Brief Review Java’s strengths Object-oriented terminology Inheritance Interfaces An example with inheritance.
The HotCiv GUI Instantiating the MiniDraw Framework.
Inheritance Revisited Other Issues. Multiple Inheritance Also called combination--not permitted in Java, but is used in C++ Also called combination--not.
M1G Introduction to Programming 2 5. Completing the program.
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.
Java Programming: From Problem Analysis to Program Design, 3e Chapter 11 Inheritance and Polymorphism.
Method Overriding Remember inheritance: when a child class inherits methods, variables, etc from a parent class. Example: public class Dictionary extends.
Deriving State…...and an example of combining behaviour.
Hints - Mandatory 2 / Strategies. Learning... life-a-curve.html B Christensen2 Jeg fatter ikke.
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.
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.
AU CSHenrik Bærbak Christensen1 dSoftArk Software Architecture Programming in the Large.
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.
Patterns are Roles What patterns are and what not…
Software Architecture Quality Attributes. Good or Bad? Measurable criterions required...
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.
Class Diagrams Revisited. Parameterized Classes Parameterized Classes - are used to represent relationships between templates.
Observations Week 4. Observe Code Change! Review week plan! Also, a load generator is added to the exercises on Iteration 3 for ‘smoking out’ the exceptions.
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.
Design Patterns Creational Patterns. Abstract the instantiation process Help make the system independent of how its objects are created, composed and.
SUBCLASSES - JAVA. The Purpose of Subclasses Class Farm String getOwner() void setOwner(String s) int getSize() void setSize(int s) Class DairyFarm String.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Hints - Mandatory 5 Blackbox Testing Pattern Hunting.
Software Architecture in Practice Architectural Prototyping.
Patterns Protect from Change Rule: if something is going to change, make it an object. Strategy: make algorithm an object so it can change State: make.
Instantiating the MiniDraw Framework
Introducing a Framework ... and a few patterns
Strategy Design Pattern
Scalability: Load Balancing
Applying the Principles
Compositional Design Principles
Presented by Igor Ivković
Presented by Igor Ivković
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:

Mandatory 3 Test Stubs State Abstract Factory

Stubs, Spies, and Fake Objects One Example Making distribution testable... Henrik Bærbak Christensen2

Ecosense Karibu framework Henrik Bærbak Christensen3 RabbitMQ Mirrored Cluster MongoDB ReplicaSet / 3 Instances

Stubs – allow us to test! Henrik Bærbak Christensen4

Happy path test Henrik Bærbak Christensen5 Send the objects Validate they are stored in the DB

... on test doubles... Henrik Bærbak Christensen6

... And simulate failure situations Henrik Bærbak Christensen7

Back to HotCiv EpsilonCiv needs a die roll –Question: How do we make automatic tests with a random die? –Answer: We do not! Analysis –The random generator in the system libraries is indirect input which must be put under testing control... Henrik Bærbak Christensen8

Also... The context of the test is difficult! What is easier and more specific to test? –O –A x d1and D x d2 Henrik Bærbak Christensen9

Which one is the Test Stub? Henrik Bærbak Christensen10

This is not Abstract Factory! Henrik Bærbak Christensen11

This is not Abstract Factory! Henrik Bærbak Christensen12 Question: How to reconfigure at run-time? What if Game needed to produce ‘product’s later (like Receipts in PayStation?) A very common trap! But it is not an Abstract Factory! Code like this – put it in the main() method

AbsFactory – UML clutter... Henrik Bærbak Christensen13

Abstract Factory Hierarchy Question: –Interface: CivFactory –Subclass: AlphaFactory implements CivFactory –??: BetaFactory extends AlphaFactory Fine – Beta IS-A Alpha with some changes, so the subclass hierarchy works out OK – but naming bad! > Figure – > AbstractFigure –RectangleFigure, CircleFigure, LineFigure,... Extend AbstractFigure Henrik Bærbak Christensen14

Abstraction and parameterization When we introduce Green and Yellow player? Henrik Bærbak Christensen15

Remember: Refactor Henrik Bærbak Christensen16 Use the flat ‘fail-fast’ strategy

Appears General – but is not Henrik Bærbak Christensen17

State – and annoying state! Who stores what? Attacks won by player Henrik Bærbak Christensen18

Problem statement When doing compositional designs we –Cut behaviour that is often otherwise in the same abstraction, and therefore have access to the same state (i.e. The same set of instance variables)... Parametric: all in the same class Polymorphic: subclasses still contain all of superclass var. –... Into multiple objects But how do they share/exchange state!!! Henrik Bærbak Christensen19

Example WinnerStrategy: Algorithm to determine winner Based upon knowledge of –Alpha: The age (correlates to rounds) –Beta: Owner of all cities –Epsilon:3 attacks won by player –Zeta:Rounds+Beta+Epsilon’ Epsilon’ = counting won attacks only starts after 20 rounds But who is responsible for ”knowing it”? Henrik Bærbak Christensen20

Example Who should know it? –Game or the WinnerStrategy or some third object? –Game/WinnerS: Number of rounds played/age –Game: Owner of all cities –WinnerS:Attacks won by player –WinnerS:Counting only starts after 20 rounds Known by Game Not really known by the Game Henrik Bærbak Christensen21

Discussion A key point here is –There is no single best answer here! Game and strategies have to collaborate rather closely in order to provide the required behaviour So – evaluate cohesion and divide responsibilities consistently, and define the protocol that allows them to exchange state changes properly –And argue for it... Henrik Bærbak Christensen22