50
1 <TITLE> © Copyright Capgemini 2008 All Rights Reserved Sander Hoogendoorn, Capgemini Rody Middelkoop, Avisi Pragmatic model driven development in Java using Pragmatic model driven development in Java using smart use cases and domain driven development smart use cases and domain driven development

20090410 J Spring Pragmatic Model Driven Development In Java Using Smart

Embed Size (px)

DESCRIPTION

In this unstable economy, organizations target software development at shorter time-to-market and high productivity. Model driven development has a promise of raising productivity in projects. However, many approach fail to deliver this promise. During this high-paced, interactive talk speakers Sander Hoogendoorn (Principal Technology Officer and agile thought leader at Capgemini) and Rody Middelkoop (Technical evangelist at Avisi, and lecturer at the Hogeschool Arnhem Nijmegen) share their very pragmatic approach to delivering software using model driven development. First, Sander will elaborate on the modeling and code generation approach, that relies on smart use cases and smart use case stereotype, a solid software architecture and domain driven design. Next, Rody will take the stage and demonstrate how this approach effects building Java web applications, generating a fully deployable Java EAR live on stage! Although other architectures and frameworks can be applied, Rody will use open source Java frameworks such as Ant, FreeMarker, Struts2, Spring and JPA/Hibernate3.

Citation preview

Page 1: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

1<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Sander Hoogendoorn, Capgemini

Rody Middelkoop, Avisi

Pragmatic model driven development in Java using Pragmatic model driven development in Java using

smart use cases and domain driven developmentsmart use cases and domain driven development

Page 2: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Sander HoogendoornSander Hoogendoorn

Capgemini

� Principal technology officer

� Capgemini agile thought leader

� Certified global software engineer (SE4)

� Chief architect Accelerated Delivery Platform

Other

� Author books (UML, agile) and articles

� Speaker at conferences

2<TITLE>© Copyright Capgemini 2008 All Rights Reserved

� Speaker at conferences

� Microsoft Partner Advisory Council .NET

� Columnist Software Release Magazine, SDN Magazine

� Editorial board Software Release Magazine

� Editorial board Tijdschrift IT Management

� Advisory board @Portunity

� Member expert panel Computable

Web

� www.sanderhoogendoorn.com

� www.accelerateddeliveryplatform.com

Page 3: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Rody MiddelkoopRody Middelkoop

Avisi

� Technical consultant

Hogeschool Arnhem Nijmegen (HAN)

� Lecturer Software Engineering

Other

� Sun Certified Java Programmer / Developer

3<TITLE>© Copyright Capgemini 2008 All Rights Reserved

� Author of several articles

� Contributor Livre

� Speaker at conferences

Web

� www.avisi.nl

� rodymiddelkoop.blogspot.com

Page 4: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

AgendaAgenda

Introduction

� Model driven development

� Pragmatic model driven development

� Our approach

� Benefite

Smart use cases

� Modeling smart use cases

� Smart use cases in code

4<TITLE>© Copyright Capgemini 2008 All Rights Reserved

� Smart use cases in code

Domain driven design

� Domain objects

� Smart references

� Value objects

Generating code

� Text templating

� Using Tobago MDA

Demo’s

Page 5: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

5<TITLE>© Copyright Capgemini 2008 All Rights Reserved

An introduction

Model driven developmentModel driven development

Page 6: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Model driven developmentModel driven development

Why?

� Bridge gap between design and code

� Improve quality of delivered software

� Raise productivity

� Achieve platform and framework independency

� Increase testability

How?

� Proprietary techniques

SH

6<TITLE>© Copyright Capgemini 2008 All Rights Reserved

� Proprietary techniques

� DSL’s (textual and graphical)

� UML

� Database

� India

What?

� Modeling tool code generation

� Development tool code generation

� Intermediate code generation

Page 7: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

7<TITLE>© Copyright Capgemini 2008 All Rights Reserved

To model driven development

A A pragmaticpragmatic approachapproach

Page 8: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Forms

Use cases

Domain

Software Architecture

TobagoMDA Frameworks

Specifications

Existing

Applications

Domain

Smartuse cases

User interface

specification1. Map your 1. Map your

business processes business processes

to smart use casesto smart use cases

1. Map your 1. Map your

business processes business processes

to smart use casesto smart use cases

4. Generate 4. Generate

code using a code using a

text template text template

engineengine

4. Generate 4. Generate

code using a code using a

text template text template

engineengine

5. Finalize your 5. Finalize your

applicationapplication

5. Finalize your 5. Finalize your

applicationapplication

8<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Domain

objects

Data / Serviceclasses

Databases

Test

scenario’s

Businessmodels

DomainModel

2. Create the 2. Create the

domain modeldomain model

2. Create the 2. Create the

domain modeldomain model3. Establish3. Establish

your software your software

architecture(s)architecture(s)

3. Establish3. Establish

your software your software

architecture(s)architecture(s)

Page 9: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

9<TITLE>© Copyright Capgemini 2008 All Rights Reserved

What makes a use cases smart?

Smart use casesSmart use cases

Page 10: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Different levels of use casesDifferent levels of use cases

Cloud level

Kite level

High summary

Summary

MergeMerge

companiescompanies

MergeMerge

mortgage systemsmortgage systems

Place Place

10<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Sea level

Fish level

Clam level

User goal

Sub-function

Too low

SelectSelect

productproduct

InsertInsert

orderlineorderline

Place Place

orderorder

Page 11: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Different levels of use casesDifferent levels of use cases

‘Regular’ 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

UnifiedVery

differentGranularity

VisualTextualFormat

Smart

use case

Regular

use case

11<TITLE>© Copyright Capgemini 2008 All Rights Reserved

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

NormalIncidentalRe-use

LikelyPossibleTraceability

in code

GoodLousyUnit of work

EasierHardEstimates

Page 12: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

12<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Modeling smart use casesModeling smart use cases

Page 13: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Modeling smart use casesModeling smart use cases

Approach

� Create a use case diagram for each

elementary business process

� Model a (user goal level) use case that

maps to the elementary business process

� Name it after the elementary business

process

13<TITLE>© Copyright Capgemini 2008 All Rights Reserved

process

� Identify the actors executing the use case

� Identify the sub-function level use cases

� Model include and extend relationships

� Identify supporting actors

Page 14: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Identifying subIdentifying sub--function level use casesfunction level use cases

Guidelines

� Identify re-use

� Model one form per use case

� Model one use case per functional web

part

� Isolate unknown functionality

14<TITLE>© Copyright Capgemini 2008 All Rights Reserved

� Isolate unknown functionality

� Identify complex functionality

� Show extensive reporting

� Model complex calculations

� Isolate interaction with others

� Avoid low level (database) interaction

Page 15: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Modeling smart use casesModeling smart use cases

15<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Page 16: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

16<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Decorating the model

Smart use case stereotypesSmart use case stereotypes

Page 17: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Smart use case stereotypesSmart use case stereotypes

What?

� Classify model elements

� Do not add meaning to model

� Define custom stereotypes

Why?

� Speed up analysis and design

RM

17<TITLE>© Copyright Capgemini 2008 All Rights Reserved

� Speed up analysis and design

� Map design to software architecture

� Generate lots of code!

� Standarize functional testing

Page 18: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

AddingAdding stereotypesstereotypes SH

18<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Page 19: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

AddingAdding stereotypesstereotypes

19<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Page 20: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Smart use case stereotypesSmart use case stereotypes

20<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Page 21: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

21<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Smart use cases and domain design

Mapping to software Mapping to software architecturearchitecture

Page 22: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Presentation

Process

Domain

Pages

UserControls

Panels

Use cases

Workflow

Domain objects / Entities

Factories / Repositories

Enums / Value objects / Smart references

22<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Data / Services

Outside world

Enums / Value objects / Smart references

[Mapping]

Table Gateways

Queries

[Mapping]

Database

Page 23: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Presentation

Process

Domain

Pages

UserControls

Panels

Use cases

Workflow

Domain objects / Entities

Factories / Repositories

Enums / Value objects / Smart references

23<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Exact SAP BizTalk Java

Data / Services

Outside world

Enums / Value objects / Smart references

[Mapping]

Service gateways

Service locators

[Mapping]

Services / ESB

Page 24: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Presentation

Process

Domain

Service contracts

Operation contracts

Data contracts

Use cases

Services

Domain objects / Entities

Factories / Repositories

Enums / Value objects / Smart references

24<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Data / Services

Outside world

Enums / Value objects / Smart references

[Mapping]

Table Gateways / Service Gateways

Queries / Service Locators

[Mapping]

Database

Services / ESB

Exact SAP BizTalk Java

Page 25: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

25<TITLE>© Copyright Capgemini 2008 All Rights Reserved

A brief introduction

Domain driven designDomain driven design

Page 26: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Domain driven designDomain driven design

Definition

� Base complex domain designs on the model

� Primary focus is on the domain and domain logic

In practice

� Model the domain

� Apply the extended domain driven vocabulary

� Build the domain layer

26<TITLE>© Copyright Capgemini 2008 All Rights Reserved

� Build the domain layer

� Hook in process layer

� Plug in data / services layer

Useful when

� The domain of your application is core

� Two tier is not (never?) desirable

� Application needs to function independent of back office, data sources or services

Page 27: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Domain driven designDomain driven design

Vocabulary

� Entity / Domain object

� Association

� Value object

� Aggregate

� Repository

27<TITLE>© Copyright Capgemini 2008 All Rights Reserved

� Repository

� Factory

� Service

Additional vocabulary

� Enumeration

� Smart reference

Page 28: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Example Example –– Class diagramClass diagram

28<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Page 29: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

29<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Properties and property types

DefiningDefining classesclasses

Page 30: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Properties and property typesProperties and property types

Basic types

� string, integer, DateTime

� Include nullable wrapping

Enumerations

� Set up at design time, unchangeable at run-time

� Genders, Categories

Value objects

� No specific instances

RM

30<TITLE>© Copyright Capgemini 2008 All Rights Reserved

� No specific instances

� Isbn, Email, Url, Money

Smart references

� Changeable at run-time, such as ContractType

Associations

� Cached domain objects such as Country, Nationality

� First level citizens such as Customer, Product

Page 31: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

31<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Value objectValue object

Page 32: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Value object Value object -- ImplementingImplementing

32<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Page 33: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Value object Value object –– In useIn use

33<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Page 34: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

34<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Smart referenceSmart reference

Page 35: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Smart reference Smart reference -- TableTable

35<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Page 36: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Smart Smart referencereference -- In In entityentity

36<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Page 37: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Smart reference Smart reference –– In useIn use

37<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Page 38: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

38<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Text templatingText templating

Page 39: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Model driven development Model driven development –– Template enginesTemplate engines

How?

� Define project

� Define patterns

� Import model

� Generate deliverable

� Finalize code

Additional features

SH

39<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Additional features

� Combine model elements

� Combine types of model elements

� Remember location

Changing the model withour losing code

� Partial classes

� Inherited classes

� Marking code

Page 40: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Tobago MDA Tobago MDA –– www.accelerateddeliveryplatform.comwww.accelerateddeliveryplatform.com

40<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Page 41: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Tobago MDATobago MDA

41<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Page 42: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Tobago MDATobago MDA

42<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Page 43: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Model driven development Model driven development -- Template enginesTemplate engines

Template engine Template engine knows (part of) knows (part of) the UML meta the UML meta

modelmodel

Template engine Template engine knows (part of) knows (part of) the UML meta the UML meta

modelmodel

Properties can Properties can be used in be used in templatestemplates

Properties can Properties can be used in be used in templatestemplates

RM

43<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Page 44: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Presentation

Process

Data / Services

Freemarker

Sitemesh

DisplayTag

Struts2

XWork Actions

EJB3 Services

EJB3 DataAccessObjects

Spring

44<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Outside world MySQL

Domain

JPA Domain objects

Enums

Value objects

Smart references

Spring

Page 45: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Model driven development Model driven development -- TemplatesTemplates

45<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Page 46: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Generate many things e.g. Table create scriptsGenerate many things e.g. Table create scripts

46<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Page 47: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

Generate many things e.g. Table create scriptsGenerate many things e.g. Table create scripts

47<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Page 48: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

48<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Demo!

Generating codeGenerating code

Page 49: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

www.accelerateddeliveryplatform.comwww.accelerateddeliveryplatform.com SH

49<TITLE>© Copyright Capgemini 2008 All Rights Reserved

Page 50: 20090410   J Spring Pragmatic Model Driven Development In Java Using Smart

50<TITLE>© Copyright Capgemini 2008 All Rights Reserved

www.accelerateddeliveryplatform.com

[email protected]

[email protected]

Twitter: aahoogendoorn LinkedIn: aahoogendoorn rodym

References and questionsReferences and questions