20101007 how smart use cases drive web development

87
Sander Hoogendoorn Principal Technology Officer Capgemini HOW SMART USE CASES DRIVE WEB DEVELOPMENT

Upload: sander-hoogendoorn

Post on 15-May-2015

5.271 views

Category:

Technology


2 download

DESCRIPTION

Use cases have been around for many years describing the requirements of software development projects. From a developer’s point of view, use cases are often seen as too abstract and too complex to develop code from. Until now, that is. During this interactive talk, presented by speaker Sander Hoogendoorn at Microsoft TechEd Europe 2010 in Berlin, will demonstrate how to model, generate and build smart use cases. This great technique allows you to model use cases at a much more pragmatic, low-granular level, enabling them to be implemented simply and directly into applications such as ASP.NET or Silverlight. Using many real-life code examples, the speaker will introduce both the positive impact that smart use cases have on your layered software architecture, as well as the design patterns required to implement them.

TRANSCRIPT

Page 1: 20101007   how smart use cases drive web development

Sander HoogendoornPrincipal Technology Officer

Capgemini

HOW SMART USE CASES DRIVE WEB DEVELOPMENT

Page 2: 20101007   how smart use cases drive web development

2HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

Capgemini

� Principal technology officer

� Global agile thought leader

� Chief architect Accelerated Delivery Platform (ADP)

Other

� Author books and +200 articles in international magazines

� Appreciated speaker at +80 international conferences

� Microsoft Partner Advisory Council .NET

� Capping IT Off Blog

� Columns in Software Release Magazine, SDN Magazine

� Editorial boards Software Release Magazine, TiTM

� Advisory board @Portunity

Web

� www.sanderhoogendoorn.com

� www.smartusecase.com

� Twitter / LinkedIn : aahoogendoorn

SANDER HOOGENDOORN

Page 3: 20101007   how smart use cases drive web development

3HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

AGENDA

Comparing requirements

techniques

Modeling

smart use cases

Smart use case driven

software architecture

Introducing

the task pattern

Generating code

from smart use cases

Unit testing

smart use cases

Page 4: 20101007   how smart use cases drive web development

4HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

AGENDA

Comparing requirements

techniques

Modeling

smart use cases

Smart use case driven

software architecture

Introducing

the task pattern

Generating code

from smart use cases

Unit testing

smart use cases

Page 5: 20101007   how smart use cases drive web development

User stories, huge cases and smart use cases

REQUIREMENT TECHNIQUES COMPARED

Page 6: 20101007   how smart use cases drive web development

6HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

USER STORIES – APPLES AND PEARS

Often too unstructured

Unsuitable in complex

environments

Page 7: 20101007   how smart use cases drive web development

7HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

COMPLEX IT LANDSCAPES

Page 8: 20101007   how smart use cases drive web development

8HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

HUGE CASES Hard to build,

impossible to test

Page 9: 20101007   how smart use cases drive web development

9HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

DIFFERENT LEVELS OF USE CASES

Cloud level

Kite level

Sea level

Fish level

Clam level

High summary

Summary

User goal

Sub-function

Too low

Products

Selling products

Search

book

Insert

orderline

Sell book

Page 10: 20101007   how smart use cases drive web development

10HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

DIFFERENT LEVELS OF USE CASES

Page 11: 20101007   how smart use cases drive web development

11HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

Traditional

use cases

Smart

use cases

Format Textual Visual

Granularity Different Unified

Estimate Hard Easy

Unit of work Lousy Good

Reuse Incidental Normal

Traceability Possible Normal

Testability Poor Good

Traditional use cases

� Only user goal level use cases

� Use cases ‘as they are intended’

� A single use case describesa single elementary business process

� Differ in granularity too much

� Law of Large Numbers does not apply

Smart use cases

� User goal and sub function level use cases

� Good unit of work and estimation

� A single elementary business process is modeledin a single use case diagram

� A single user goal level use case + auxiliary use cases at sub-function level

� Very similar granularity

DIFFERENT LEVELS OF USE CASES

Page 12: 20101007   how smart use cases drive web development

12HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

AGENDA

Comparing requirements

techniques

Modeling

smart use cases

Smart use case driven

software architecture

Introducing

the task pattern

Generating code

from smart use cases

Unit testing

smart use cases

Page 13: 20101007   how smart use cases drive web development

A YAGNI approach to requirements

SMART USE CASES

Page 14: 20101007   how smart use cases drive web development

14HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

In traditional software development

� Analysis and design is done upfront

� Development only starts after all design is complete and perfect

Consequences

� No room for new or changing insights

� Possibly unnecessary work

Therefore

� Eliminate waste

� Maximize the amount of work not done

� Postpone work until you really need it

Benefits

� No unnecessary analysis and design work

� Allows for new and changing insights

� No handover, immediate feedback

YAGNI. YOU AIN’T GONNA NEED IT

Page 15: 20101007   how smart use cases drive web development

15HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

AGILE REQUIREMENTS - APPROACH

D

E

F

SmartUse Cases

A

Project

Scope

D

Use Cases

A

B C

Hierarchical

Processes

B

D

D

Hierarchical

Processes

Chronological

Processes

Cloud Level Kite Level Sea Level Fish Level

C

Page 16: 20101007   how smart use cases drive web development

16HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

CLOUD LEVEL

Page 17: 20101007   how smart use cases drive web development

17HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

KITE LEVEL

Page 18: 20101007   how smart use cases drive web development

18HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

Guidelines

� Identify re-use

� Model one form per use case

� Model one use case per web part

� Isolate unknown or complex functionality

� Model complex calculations

� Identify reports and analysis

� Isolate interaction with others

� Model services in service orientation

� Avoid low level interaction

(database, technical services)

IDENTIFYING SUB-FUNCTION LEVEL USE CASES

Page 19: 20101007   how smart use cases drive web development

19HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

MODELING SMART USE CASES

Page 20: 20101007   how smart use cases drive web development

20HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

MODELING SMART USE CASES – SEA AND FISH LEVEL

Page 21: 20101007   how smart use cases drive web development

21HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

DESCRIBING USE CASES – SEA AND FISH LEVEL

Page 22: 20101007   how smart use cases drive web development

Stereotypes

SMART USE CASES

Page 23: 20101007   how smart use cases drive web development

23HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

Stereotypes in UML

� Marking model items gives explicit meaning to

the model

� Predefined stereotypes

� Custom definable stereotypes

Smart use case stereotypes

� Standardize analysis and design

� “This is a master-detail on product and order”

� “This service on customer is an aggregate”

� “We need a file import for handling the XMI”

� Facilitate easy estimation

� Commoditize realization of smart use case

� Facilitate easier (and automated) testing

SMART USE CASE STEREOTYPES

Page 24: 20101007   how smart use cases drive web development

24HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

AGENDA

Comparing requirements

techniques

Modeling

smart use cases

Smart use case driven

software architecture

Introducing

the task pattern

Generating code

from smart use cases

Unit testing

smart use cases

Page 25: 20101007   how smart use cases drive web development

An overview

SMART USE CASE DRIVEN ARCHITECTURE

Page 26: 20101007   how smart use cases drive web development

26HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

Database consumer

� Domain oriented

� Data provided by database(s)

� But often database independent

Service consumer

� Domain oriented

� Data provided by service or middleware

� But protocol independent (SOAP or REST?)

Service provider

� Service oriented

� Data provided by contacts

� But domain oriented using data contracts

USING REFERENCE ARCHITECTURES

Page 27: 20101007   how smart use cases drive web development

27HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

Presentation

Process

Domain

Data / Services

Outside world

Pages

UserControls

Panels

Use cases

Workflow

Domain objects / Entities

Factories / Repositories

Enums / Value objects / Smart references

[Mapping]

Table Gateways

Queries

[Mapping]

Database

Page 28: 20101007   how smart use cases drive web development

28HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

Exact SAP BizTalk Java

Presentation

Process

Domain

Data / Services

Outside world

Pages

UserControls

Panels

Use cases

Workflow

Domain objects / Entities

Factories / Repositories

Enums / Value objects / Smart references

[Mapping]

Service gateways

Service locators

[Mapping]

Services / ESB

Page 29: 20101007   how smart use cases drive web development

29HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

Presentation

Process

Domain

Data / Services

Outside world

Service contracts

Operation contracts

Data contracts

Use cases

Services

Domain objects / Entities

Factories / Repositories

Enums / Value objects / Smart references

[Mapping]

Table Gateways / Service Gateways

Queries / Service Locators

[Mapping]

Database

Services / ESB

Exact SAP BizTalk Java

Page 30: 20101007   how smart use cases drive web development

30HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

ARCHITECTURE IN CODE

Web

� Pages, controls

Process

� Use cases / Tasks / Flow

Domain

� Factories / Repositories

� Domain Objects / Business rules

� Enums / Value Objects / References

� Search Objects

Data / Services

� Gateways

� Mappings / Describers

Database

Page 31: 20101007   how smart use cases drive web development

31HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

AGENDA

Comparing requirements

techniques

Modeling

smart use cases

Smart use case driven

software architecture

Introducing

the task pattern

Generating code

from smart use cases

Unit testing

smart use cases

Page 32: 20101007   how smart use cases drive web development

Introducing the Task Pattern

SMART USE CASE DRIVEN ARCHITECTURE

Page 33: 20101007   how smart use cases drive web development

33HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

Presentation

Process

Domain

Data / Services

Outside world

Pages

UserControls

Panels

Use cases

Workflow

Domain objects / Entities

Factories / Repositories

Enums / Value objects / Smart references

[Mapping]

Table Gateways

Queries

[Mapping]

Database

Page 34: 20101007   how smart use cases drive web development

34HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

Smart use cases

� Act as primary unit of work

� Model process and work flow

� Make traceable in code

� Interact with presentation and domain layers

� Create layer supertype (task)

� Create classes for individual smart use cases

Why?

� Create traceability

� Facilitate reuse

� Implement model view controller

� Facilitate easier functional testing

� Cheapen application maintenance

SMART USE CASES IN CODE

Page 35: 20101007   how smart use cases drive web development

35HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

SMART USE CASES IN CODE

Page 36: 20101007   how smart use cases drive web development

36HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

Command pattern – Definition

� Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations

Task pattern – Definition

� Encapsulate a smart use case as an object, thereby letting you parameterize it from different requests.

In practice

� Implement smart use cases independently

� Define a navigation mechanism

� Use smart use cases independently

� Allows for reuse of your smart use cases!

Useful when

� Always ☺

� Create a task manager!

TASK PATTERN

Page 37: 20101007   how smart use cases drive web development

37HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

TASK PATTERN

Page 38: 20101007   how smart use cases drive web development

38HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

TASK PATTERN IN PRACTICE

Page 39: 20101007   how smart use cases drive web development

39HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

TASK PATTERN IN PRACTICE – RUNNING A USE CASE

Page 40: 20101007   how smart use cases drive web development

40HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

TASK PATTERN

Page 41: 20101007   how smart use cases drive web development

41HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

TASK PATTERN – START FIRST USE CASE

Page 42: 20101007   how smart use cases drive web development

42HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

TASK PATTERN – START SECOND USE CASE

Page 43: 20101007   how smart use cases drive web development

43HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

TASK PATTERN – WEB PAGE WITH SECOND USE CASE

Page 44: 20101007   how smart use cases drive web development

44HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

TASK PATTERN – POST CONDITIONS SECOND USE CASE

Page 45: 20101007   how smart use cases drive web development

45HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

TASK PATTERN – CONTINUE FIRST USE CASE

Page 46: 20101007   how smart use cases drive web development

46HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

TASK PATTERN – WEB PAGE WITH FIRST USE CASE

Page 47: 20101007   how smart use cases drive web development

47HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

TASK PATTERN – POST CONDITIONS FIRST USE CASE

Page 48: 20101007   how smart use cases drive web development

Task management with the Manager-Provider Pattern

SMART USE CASE DRIVEN ARCHITECTURE

Page 49: 20101007   how smart use cases drive web development

49HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

Definition

� Create a simple static facade (manager) for a

(set of) interfaced implementations (providers)

In practice

� Manager holds one or a collection of providers

� Provider implement a particular interface

� Manager has methods to call methods from

interface

� At run-time, using dependency injection, actual

providers are injected

MANAGER-PROVIDER PATTERN

Page 50: 20101007   how smart use cases drive web development

50HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

MANAGER – VALIDATIONMANAGER

Page 51: 20101007   how smart use cases drive web development

51HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

INTERFACE

Page 52: 20101007   how smart use cases drive web development

52HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

MANAGER – INITIALIZATION (USING DEPENDENCY INJECTION)

Page 53: 20101007   how smart use cases drive web development

53HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

CONFIGURATION OF IMPLEMENTATION

Page 54: 20101007   how smart use cases drive web development

54HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

MANAGER - EXECUTING METHODS

Page 55: 20101007   how smart use cases drive web development

55HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

CLIENT – CALLING METHODS

Page 56: 20101007   how smart use cases drive web development

56HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

Useful when

� Generic services need to be called, which may have different implementations

� Manager prevents having to loop through each of a list of providers

� Flexibility to add or remove providers without changing application code

� Providers differ e.g. in development code, test code or deployed code

Use for

� Task Management

� View Management

� Binding and Persisting

� Resource Management

� State Management

� Logging

� Datasource interaction

� Testing!

MANAGER-PROVIDER PATTERN

Page 57: 20101007   how smart use cases drive web development

57HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

AGENDA

Comparing requirements

techniques

Modeling

smart use cases

Smart use case driven

software architecture

Introducing

the task pattern

Generating code

from smart use cases

Unit testing

smart use cases

Page 58: 20101007   how smart use cases drive web development

An introduction to pragmatic model driven development

GENERATING CODE FROM SMART USE CASES

Page 59: 20101007   how smart use cases drive web development

59HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

Forms

Use cases

Domain

objects

Data / Serviceclasses

Databases

Software Architecture

TobagoMDA

Test

scenario’s

Frameworks

Specifications

Existing

Applications

Businessmodels

DomainModel

Smartuse cases

User interface

specification1. Map your

business processes

to smart use cases

1. Map your

business processes

to smart use cases

2. Set up your

domain model

2. Set up your

domain model3. Establish

your software

architecture(s)

3. Establish

your software

architecture(s)

4. Generate

your code using

a text template

engine

4. Generate

your code using

a text template

engine

5. Finalize your

application

5. Finalize your

application

Page 60: 20101007   how smart use cases drive web development

60HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

Characteristics

� Load UML model (expressed in XMI)

� Load templates (from flat files)

� Combine elements from UML model with templates to generate deliverables

Templates

� Templates contains code that runs in template engine

� Templates might use a folder model

Generation process

� Ability to generate all or individual UML model elements

� Which UML model elements are supported?

� Generated deliverables can be code but also any other document type

MODEL DRIVEN DEVELOPMENT – TEMPLATE ENGINES

Page 61: 20101007   how smart use cases drive web development

61HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

MODEL DRIVEN DEVELOPMENT - TEMPLATE ENGINES

Template engine knows (part of) the UML meta

model

Template engine knows (part of) the UML meta

model

Properties can be used in templates

Properties can be used in templates

Page 62: 20101007   how smart use cases drive web development

62HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

MODEL DRIVEN DEVELOPMENT - TEMPLATES

Page 63: 20101007   how smart use cases drive web development

63HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

GENERATE MANY THINGS E.G. TABLE CREATE SCRIPTS

Page 64: 20101007   how smart use cases drive web development

A quick example

GENERATING CODE

Page 65: 20101007   how smart use cases drive web development

65HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

A SIMPLE SMART USE CASE MODEL

uc Manage Customer

Site Administrator

(from A ctors)

«master detail»

Manage Customer

«search»

Select Customer

«define»

Define Contact

«extend»

«incl ude»

Page 66: 20101007   how smart use cases drive web development

66HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

A SIMPLE DOMAIN MODEL

class Budapest.Business

«business class»

Cust omer

+ Name: string

+ Address: string

+ Postcode: Postcode

+ City: string

+ Country: SmartRef

+ Website: Url [0..1]

«business class»

Contact

+ Name: string

+ Email: Email [0..1]

+ Phone: PhoneNumber [0..1]

+ Department: Departments

«enumeration»

Depart ments

Sal es

Purchasing

Helpdesk

Management

*

Page 67: 20101007   how smart use cases drive web development

67HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

USING TOBAGO MDA

Page 68: 20101007   how smart use cases drive web development

68HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

GENERATED CODE IN ASP.NET

Page 69: 20101007   how smart use cases drive web development

69HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

GENERATED CODE IN SILVERLIGHT

Page 70: 20101007   how smart use cases drive web development

70HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

AGENDA

Comparing requirements

techniques

Modeling

smart use cases

Smart use case driven

software architecture

Introducing

the task pattern

Generating code

from smart use cases

Unit testing

smart use cases

Page 71: 20101007   how smart use cases drive web development

Unit testing at the right level

UNIT TESTING SMART USE CASES

Page 72: 20101007   how smart use cases drive web development

72HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

Presentation

Process

Domain

Data / Services

Outside world

Pages

UserControls

Panels

Use cases

Workflow

Domain objects / Entities

Factories / Repositories

Enums / Value objects / Smart references

[Mapping]

Table Gateways

Queries

[Mapping]

Database

Page 73: 20101007   how smart use cases drive web development

73HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

UNIT TESTING SMART USE CASES

Unit test what?

� Methods from the task pattern

� Methods that are called from presentation

� Methods that collaborate with other use cases

� Methods that interact with domain

How?

� Create unit test for each smart use case

� Run methods from smart use case

� Validate outcome (using asserts)

Why?

� Great code coverage

� Regressions testing on smart use cases

� Code generation makes light work

Page 74: 20101007   how smart use cases drive web development

74HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

UNIT TESTING SMART USE CASES

Test methods from Task Pattern

Run method

Validate outcome

Page 75: 20101007   how smart use cases drive web development

75HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

UNIT TESTING SMART USE CASES

Test methods that interact with domain

Set up (in)valid domain object

Run method from use case

Validate outcome

Page 76: 20101007   how smart use cases drive web development

Introducing a light weight smart use case unit testing framework

UNIT TESTING SMART USE CASES

Page 77: 20101007   how smart use cases drive web development

77HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

Test environment

� Create test manager (using manager-provider)

� Mock actual use case environment

� Log events from environment to test manager

� Asserts by querying test manager

Task management

� (Possibly) avoid other task getting started

View management

� Don’t request actual web pages or forms

� Method calls from web pages are tested

Domain

� Handle actual validation, saves, removes

� Make sure business rules validate

Validation

� Validate, but handle by logging

A LIGHTWEIGHT SMART USE CASE UNIT TESTING FRAMEWORK

Page 78: 20101007   how smart use cases drive web development

78HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

CONFIGURING TEST ENVIRONMENT

Page 79: 20101007   how smart use cases drive web development

79HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

TEST MANAGER – LOGGING EVENTS

Page 80: 20101007   how smart use cases drive web development

80HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

MOCKING ENVIRONMENT – LOGGING EVENTS

Page 81: 20101007   how smart use cases drive web development

81HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

TEST MANAGER – QUERYING EVENTS

Page 82: 20101007   how smart use cases drive web development

82HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

TEST MANAGER – RUNNING TESTS

Test methods that interact with domain

Set up (in)valid domain object

Run method from use case

Validate outcome

Page 83: 20101007   how smart use cases drive web development

TAKEAWAYS

Page 84: 20101007   how smart use cases drive web development

84HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

Smart use cases

� Solid unit of work in agile projects

� Easy estimation

� Identifying functional re-use early in projects

� Guarantee front-to-back traceability

� Great unit for (automated) testing

� Apply stereotypes for even more

standardization

� Use a REAL modeling tool

Software architecture

� Provide separate smart use cases layer

� Handles process, interaction and work flow

� Controller ++

TAKEAWAYS

Page 85: 20101007   how smart use cases drive web development

85HOW SMART USE CASES DRIVE WEB DEVELOPMENT©2010 Capgemini. All Rights Reserved

Coding

� Implement task pattern

� Implement task management

� Modeling provides for model driven

development

Testing

� Smart use cases allow for automated testing

� Great code coverage on all layers

� Mock actual task environment

� Run tests automated in nightly builds

TAKEAWAYS

Page 86: 20101007   how smart use cases drive web development

www.accelerateddeliveryplatform.com

WWW.SMARTUSECASE.COM

Page 87: 20101007   how smart use cases drive web development

[email protected]

www.sanderhoogendoorn.com

www.smartusecase.com

@aahoogendoorn

REFERENCES AND QUESTIONS