Weitere ähnliche Inhalte Ähnlich wie 20101007 how smart use cases drive web development (20) Mehr von Sander Hoogendoorn (20) Kürzlich hochgeladen (20) 20101007 how smart use cases drive web development2. 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
3. 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
4. 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
6. 6HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
USER STORIES – APPLES AND PEARS
Often too unstructured
Unsuitable in complex
environments
7. 7HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
COMPLEX IT LANDSCAPES
8. 8HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
HUGE CASES Hard to build,
impossible to test
9. 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
10. 10HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
DIFFERENT LEVELS OF USE CASES
11. 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 describes
a 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 modeled
in 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
12. 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
14. 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
15. 15HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
AGILE REQUIREMENTS - APPROACH
D
E
F
Smart
Use 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
16. 16HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
CLOUD LEVEL
17. 17HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
KITE LEVEL
18. 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
19. 19HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
MODELING SMART USE CASES
20. 20HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
MODELING SMART USE CASES – SEA AND FISH LEVEL
21. 21HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
DESCRIBING USE CASES – SEA AND FISH LEVEL
23. 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
24. 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
26. 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
27. 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
28. 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
29. 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
30. 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
31. 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
33. 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
34. 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
35. 35HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
SMART USE CASES IN CODE
36. 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
37. 37HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
TASK PATTERN
38. 38HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
TASK PATTERN IN PRACTICE
39. 39HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
TASK PATTERN IN PRACTICE – RUNNING A USE CASE
40. 40HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
TASK PATTERN
41. 41HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
TASK PATTERN – START FIRST USE CASE
42. 42HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
TASK PATTERN – START SECOND USE CASE
43. 43HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
TASK PATTERN – WEB PAGE WITH SECOND USE CASE
44. 44HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
TASK PATTERN – POST CONDITIONS SECOND USE CASE
45. 45HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
TASK PATTERN – CONTINUE FIRST USE CASE
46. 46HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
TASK PATTERN – WEB PAGE WITH FIRST USE CASE
47. 47HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
TASK PATTERN – POST CONDITIONS FIRST USE CASE
49. 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
50. 50HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
MANAGER – VALIDATIONMANAGER
51. 51HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
INTERFACE
52. 52HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
MANAGER – INITIALIZATION (USING DEPENDENCY INJECTION)
53. 53HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
CONFIGURATION OF IMPLEMENTATION
54. 54HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
MANAGER - EXECUTING METHODS
55. 55HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
CLIENT – CALLING METHODS
56. 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
57. 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
58. An introduction to pragmatic model driven development
GENERATING CODE FROM SMART USE CASES
59. 59HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
Forms
Use cases
Domain
objects
Data / Service
classes
Databases
Software Architecture
Tobago
MDA
Test
scenario’s
Frameworks
Specifications
Existing
Applications
Business
models
Domain
Model
Smart
use cases
User interface
specification
1. 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 model
3. 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
60. 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
61. 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
62. 62HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
MODEL DRIVEN DEVELOPMENT - TEMPLATES
63. 63HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
GENERATE MANY THINGS E.G. TABLE CREATE SCRIPTS
65. 65HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
A SIMPLE SMART USE CASE MODEL
uc Manage Customer
Site Administrator
(from Actors)
«master detail»
Manage Customer
«search»
Select Customer
«define»
Define Contact
«extend»
«include»
66. 66HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
A SIMPLE DOMAIN MODEL
class Budapest.Business
«business class»
Customer
+ 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»
Departments
Sales
Purchasing
Helpdesk
Management
*
67. 67HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
USING TOBAGO MDA
68. 68HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
GENERATED CODE IN ASP.NET
69. 69HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
GENERATED CODE IN SILVERLIGHT
70. 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
72. 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
73. 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
74. 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
75. 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
76. Introducing a light weight smart use case unit testing framework
UNIT TESTING SMART USE CASES
77. 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
78. 78HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
CONFIGURING TEST ENVIRONMENT
79. 79HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
TEST MANAGER – LOGGING EVENTS
80. 80HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
MOCKING ENVIRONMENT – LOGGING EVENTS
81. 81HOW SMART USE CASES DRIVE WEB DEVELOPMENT
©2010 Capgemini. All Rights Reserved
TEST MANAGER – QUERYING EVENTS
82. 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
84. 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
85. 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