(The obligatory second...

15
MDA: Nice Principles, Shame about the ... © 2004 Haywood Associates Ltd. 1 Agile MDA: Naked Objects & Together Control Center Agile MDA: Naked Objects & Together Control Center Dan Haywood Haywood Associates Ltd. Page 2 © 2005 Haywood Associates Ltd. (The obligatory second slide) (The obligatory second slide) Expert in Together CC Author of "Better Software Faster" "In the best of all worlds, every IT professional and every business person who wants an IT system would read Better Software Faster." Ed Yourdon Expert in Naked Objects Through 2004/5, working with NO founders at the DSFA business object modelling contributing to the NO framework itself Various articles e.g. Naked Objects series, TheServerSide.com I'm an independent consultant / developer / trainer… Java, J2EE, .Net, RDBMS, OO, UML, AOP/AspectJ I like the ideas behind MDA … … just not the execution

Transcript of (The obligatory second...

MDA: Nice Principles, Shame about the ...

© 2004 Haywood Associates Ltd. 1

Agile MDA:Naked Objects &

Together Control Center

Agile MDA:Naked Objects &

Together Control Center

Dan HaywoodHaywood Associates Ltd.

Page 2 © 2005 Haywood Associates Ltd.

(The obligatory second slide)(The obligatory second slide)

Expert in Together CCAuthor of "Better Software Faster"

"In the best of all worlds, every IT professional and every business person who wants an IT system would read Better Software Faster."

Ed Yourdon

Expert in Naked ObjectsThrough 2004/5, working with NO founders at the DSFA

business object modellingcontributing to theNO framework itself

Various articlese.g. Naked Objects series, TheServerSide.com

I'm an independent consultant / developer / trainer…Java, J2EE, .Net, RDBMS, OO, UML, AOP/AspectJ

I like the ideas behind MDA …… just not the execution

MDA: Nice Principles, Shame about the ...

© 2004 Haywood Associates Ltd. 2

Page 3 © 2005 Haywood Associates Ltd.

A bit about MDA…Raising the Level of AbstractionA bit about MDA…Raising the Level of Abstraction

Abstraction means omitting detailRaising the level means omitting more detail

Thus, cannot be dependent on that detailin particular, not dependent on platform specificsfocus on the remaining important details

e.g. the domain model

But, need to regain missing detail to deploy

provide a mapping to lower abstraction levelsthe mapping itself can encode best practice

Page 4 © 2005 Haywood Associates Ltd.

A bit about MDA…

MappingsA bit about MDA…

Mappings

Refiningmore less abstracte.g code generators

Abstractingless more abstracte.g. filtering

Representingassociate models from different metamodelse.g. UML class diagram & Java source code

Migratinglightweight conversione.g. if change Case tool

Mergingcombines orthogonal models

MDA: Nice Principles, Shame about the ...

© 2004 Haywood Associates Ltd. 3

Page 5 © 2005 Haywood Associates Ltd.

A bit about MDA…

Two approaches to MDAA bit about MDA…

Two approaches to MDATwo principal approaches

Elaborationist approachTranslationist (executable model) approach

Page 6 © 2005 Haywood Associates Ltd.

A bit about MDA…

Abstraction & ElaborationA bit about MDA…

Abstraction & ElaborationUnder the elaborationist approach

PIM abstracts out platform detailsPSM is an elaboration (i.e. fills in the detail)

e.g. UML class to EJB classes +/or RDBMS tablesQVT spec aims to standardize this elaboration

PSM elaborated further to codePIM is marked up to direct the mapping process

PSM or code can be editede.g. to add in expressions of behaviour

PIM PSMmapping Codecompiler

MDA: Nice Principles, Shame about the ...

© 2004 Haywood Associates Ltd. 4

Page 7 © 2005 Haywood Associates Ltd.

A bit about MDA…

Abstraction & TranslationA bit about MDA…

Abstraction & TranslationUnder the translationist model

collection of orthogonal modelseach represents a single aspect

for the domain, or for system concerns

models are marked up to indicate bindings to each otherbridges between the different models

Resultant code is not edited⇒ all behaviour expressed in models

DomainModel

Codemodeltranslator

SystemModel

Page 8 © 2005 Haywood Associates Ltd.

A bit about MDA…Some questions to be mullingA bit about MDA…Some questions to be mulling

Do models matter?does the business care about the model?are the incentives (to the business) right?how stable is the business, anyway?

Is UML the right language?

Is platform independence doable?

MDA: Nice Principles, Shame about the ...

© 2004 Haywood Associates Ltd. 5

Page 9 © 2005 Haywood Associates Ltd.

Naked ObjectsNaked ObjectsA radical approach to business systems designAnd also

a book, an open source framework, a PhD thesis and a company

Page 10 © 2005 Haywood Associates Ltd.

Naked Objects

Yes, but what is it?Naked Objects

Yes, but what is it?An architectural pattern (among other things)Automatic visualization of behaviourally complete objects

Presentation

Application, Process, Task or Controller

Domain object model

Persistence

MDA: Nice Principles, Shame about the ...

© 2004 Haywood Associates Ltd. 6

Page 11 © 2005 Haywood Associates Ltd.

(Behaviourally complete)

Naked Objects

The Naked Objects PatternNaked Objects

The Naked Objects PatternEliminates the use case controller layer

encapsulate functionality back in the domain model

Presentation

Domain object model

Persistence

(We simplify here a little for thesake of a good slide sequence…)

Page 12 © 2005 Haywood Associates Ltd.

Naked Objects

The Naked Objects PatternNaked Objects

The Naked Objects PatternGeneric presentation layer reflects the domain model

as an object-oriented user interface

Domain object model

Persistence

(Behaviourally complete)

MDA: Nice Principles, Shame about the ...

© 2004 Haywood Associates Ltd. 7

Page 13 © 2005 Haywood Associates Ltd.

Naked Objects

The Naked Objects PatternNaked Objects

The Naked Objects PatternAuto-generate the persistence layer

for a standalone system or if prototyping

(Behaviourally complete)Domain object model

Page 14 © 2005 Haywood Associates Ltd.

Rosa's Breakfast Service

The ModelRosa's Breakfast Service

The ModelUsing TCC to visualize the "PIM"

Case study fromMDA ExplainedKleppe, Warmer & Bast(Addison-Wesley, 2003)

"Breakfast in bed" foryour loved one

0..*

1

0..* 1

1

0..*

1

1

1

0..* 1

0..* 1

0..*1

1

1..*

1

0..*

1

adapters.BusinessObjectBreakfastOrder

+actionCalculateTotal:void+actionAddBreakfast:void+createTransientInstance:B

{r} total:Money{rw} address:Address{r} deliveryDate:Date{r} deliveryTime:Time{r} discount:Money{r} orderDate:Date{r} breakfasts:InternalColle{rw} customer:Customer

adapters.BusinessObjectBreakfast

+actionChangeComestible:v+actionChangeComestible:v+create:Breakfast

{r} number:WholeNumber{r} changes:InternalCollect{rw} standardBreakfast:Sta

adapters.BusinessObjectChange

+aboutBreakfast:void+aboutComestible:void+createTransientInstance:C

{r} quantity:WholeNumber{rw} breakfast:Breakfast{rw} comestible:Comestible

adapters.BusinessObjectComestible

+createTransientInstance:C+setup:Comestible

{r} name:TextString{r} minimalQuantity:Whole{r} price:Money{r} transportForm:TextStri

adapters.BusinessObjectCustomer

+actionCreateOrder:Breakfa+createTransientInstance:C+setup:Customer

{r} accountNumber:WholeN{r} breakfastOrders:Interna{rw} address:Address

adapters.BusinessObjectAddress

{r} streetNumber:TextStrin{r} street:TextString{r} city:TextString{r} postalCode:TextString{r} telephoneNumber:TextS

adapters.BusinessObjectStandardBreakfast

+actionAddComestible:Part+createTransientInstance:S+setup:StandardBreakfast+findByTitle:StandardBreakf

{r} name:TextString{r} parts:InternalCollection{r} price:Money{rw} style:Style

adapters.BusinessObjectPart

+createTransientInstance:Pa

{r} quantity:WholeNumber{rw} standardBreakfast:Sta{rw} comestible:Comestible

adapters.BusinessObjectStyle

+createTransientInstance:S+setup:Style

{r} number:WholeNumber{r} name:TextString

MDA: Nice Principles, Shame about the ...

© 2004 Haywood Associates Ltd. 8

Page 15 © 2005 Haywood Associates Ltd.

Rosa's Breakfast Service

The Running ApplicationRosa's Breakfast Service

The Running Application

(Demo)

Page 16 © 2005 Haywood Associates Ltd.

public void actionCalculateTotal() {Money price = new Money();price.setValue(0);// price of standard breakfast's partsfor (Enumeration enum = this.breakfasts.elements();

enum.hasMoreElements();) {Breakfast breakfast = (Breakfast)enum.nextElement();Map quantitiesByComestible = new HashMap();StandardBreakfast sb = breakfast.getStandardBreakfast();if (sb != null) {

for (Enumeration enum2 = sb.getParts().elements();enum2.hasMoreElements();) {

Part part = (Part)enum2.nextElement();if (part.getComestible() != null) {

quantitiesByComestible.put( part.getComestible(), new int[] { part.getQuantity().intValue() } );

}}

}// price of any changes for this breakfast…// apply discount (if any)price.subtract(getDiscount());getTotal().setValue(price);objectChanged(); // workaround for bug in NO framework

return;}

Rosa's Breakfast ServiceThe CodeRosa's Breakfast ServiceThe Code

Application consists of domain classes only

MDA: Nice Principles, Shame about the ...

© 2004 Haywood Associates Ltd. 9

Page 17 © 2005 Haywood Associates Ltd.

Rosa's Breakfast ServiceUsing Together for DocumentationRosa's Breakfast ServiceUsing Together for Documentation

(Demo)

Page 18 © 2005 Haywood Associates Ltd.

Rosa's Breakfast Service

eXecutable Acceptance TestsRosa's Breakfast Service

eXecutable Acceptance TestsThe NO framework also has its own testing frameworkAllows user interactionsto be scripted as JUnit testsFixtures are shared withapplication itself

failing tests can easily be verified

Moreoverat compile time, Together can create user-reviewable documents from the test source codeat run time, XATs create a journal as each test passes

XATs are used as the basis for:business rule definitionscenario testing (UAT)

MDA: Nice Principles, Shame about the ...

© 2004 Haywood Associates Ltd. 10

Page 19 © 2005 Haywood Associates Ltd.

Rosa's Breakfast Service

eXecutable Acceptance TestsRosa's Breakfast Service

eXecutable Acceptance Tests

We're being agile, so let's do a quick mod… ☺

Public Sub testCanCreateBreakfastOrder()cust111.assertActionUsable( _

"Create Order", _params(New NoDate, New NoTime, New Money))

End Sub

Public Sub testCreateDefaultsCustomerAndParameters()Dim newOrder As TestObject = _cust111.invokeAction( _

"Create Order", _params(New NoDate(2003, 4, 1), _

New NoTime(7, 45), _New Money(20.0))

newOrder.assertFieldContains( _"Customer", cust111)

newOrder.assertFieldContains( _"Delivery Time", New NoTime(7, 45))

newOrder.assertFieldContains( _"Delivery Date", New NoDate(2003, 4, 1))

newOrder.assertFieldContains( _"Discount", New Money(20.0))

End Sub

Page 20 © 2005 Haywood Associates Ltd.

Naked Objects & Together

The DRY PrincipleNaked Objects & Together

The DRY Principle"Every piece of system knowledge should have one authoritative, unambiguous representation. Every piece of knowledge in the development of something should have a single representation. A system's knowledge is far broader than just its code. It refers to database schemas, test plans, the build system, even documentation."

Dave Thomas (Pragmatic Programmer)

Naked Objects & Together CC make this achievable

At compile timeTogether CC itself

sync model and codeDocumentation generation

XATs for customersBOM for developers

At run timeThe NO pattern itself

sync domain and UIXAT journal

(and I'll talk about the database next slide)

MDA: Nice Principles, Shame about the ...

© 2004 Haywood Associates Ltd. 11

Page 21 © 2005 Haywood Associates Ltd.

Naked Objects

Deploy to your favourite platformNaked Objects

Deploy to your favourite platformNaked Objects framework is written in Java 1.1

compiles to class files, run on JVMcompiles to IL, run under .NET

Write domain objects in your favourite languagefor Java/J2EE, typically just Javafor .NET, any of C#, VB.Net, J#

Domain objects are (typically) just POJOsno compile-time dependencies on framework

can define your own programming model semantics

can be tested outside the frameworkintegrate seamlessly with other POJO-based frameworks

Deploy to an app servereither J2EE or IIS

Page 22 © 2005 Haywood Associates Ltd.

Naked ObjectsA quick peek at the ArchitectureNaked ObjectsA quick peek at the Architecture

Container instantiates concrete instances and sets up dependencies

Proxy Object Manager services pre- and post-conditions locally, but delegates actions

Local Object Manager services actions

PC Client

User Manager

Viewing Mechanism Meta Model

Proxy Container

Proxy Object Manager

BOM Objects

Application Server

Dispatcher

Local Object Manager

BOM Objects

RDBMS Object Store

User Manager

Container

Transaction Manager

Meta Model

RDBMS

Database

MDA: Nice Principles, Shame about the ...

© 2004 Haywood Associates Ltd. 12

Page 23 © 2005 Haywood Associates Ltd.

NO/TCC in the context of MDANO/TCC in the context of MDAVery definitely in the translationist camp

Domain model comes to the forerepresented in UML (courtesy of TCC) or inOO programming language

Other aspects implemented by frameworkvisualization, persistence & transactions,security, distribution

We don't attempt platform independenceyou'll have to make do with either Java or .Net

Use Java or .Net languages to specify behaviournot a new imperative language (ASL)not a declarative language (eg OCL)

Page 24 © 2005 Haywood Associates Ltd.

NO/TCC in the context of MDA

Do models matter?NO/TCC in the context of MDA

Do models matter?Only if they are exhibit immediate value

to the businessto the developers

Does the business care about the model?yes – its relationship to the running application is clearamazing connection to the domain model

at high levels of management seniority

Are the incentives (to the business) right?there is no expensive mapping process to debuganyway, we don't focus on reuse

"a good result but a poor objective"

How stable is the business?it doesn't matter: this is agile developmentthe model is the code

just focusingon the business'viewpoint

MDA: Nice Principles, Shame about the ...

© 2004 Haywood Associates Ltd. 13

Page 25 © 2005 Haywood Associates Ltd.

NO/TCC in the context of MDA

Is UML the right language?NO/TCC in the context of MDA

Is UML the right language?No, not really.

UML is very strong on static structuresclass diagrams in particular

But is much weaker on behavioural structuresstate charts work to an extent

proven for real-time domains, but not elsewhereinteraction diagrams are instance-, not type-basedOCL is declarative, not imperativeASL is a new language with no concrete syntax

coupling to vendor's implementation

AOP languages provides similar abstractions, exceptOffer clear lineage with OO languagesUML profiles (or other graphical notations) not yet standardized

Page 26 © 2005 Haywood Associates Ltd.

NO/TCC in the context of MDAIs platform independence doable?NO/TCC in the context of MDAIs platform independence doable?

Would like tocreate a platform-independent representation …

complete in and of itself… then bind it to an implementation

through some mechanism or another

To do so meansadopting a formalism to describe that representation

that is, UML and either ASLadopting mappings to elaborate / translate those models

either proprietary or based on QVTinvesting in mappings for today's run-time platforms

At best, we can be independent of run-time platform …Though elaborationist approach can't really manage even this

(typically that's where behaviour must be specified)

… but we can't be independent at development-timeneed to depend on tools to capture models & perform mappings

MDA: Nice Principles, Shame about the ...

© 2004 Haywood Associates Ltd. 14

Page 27 © 2005 Haywood Associates Ltd.

What to do…?What to do…?MDA describes a problem worth solving

bind a problem domain to an implementation technology

Best bet is to be pragmaticFor business systems, target support both .NET and Java

both use a VM, so we can expect long lifetimesUse a 3GL to express behaviourReuse a fundamental architectural style

that is platform independentUse a POJO-based solution

no coupling to vendor

And while you're at it, employ agile principles

Page 28 © 2005 Haywood Associates Ltd.

Summary Summary It's all about binding the PIM to the implementation

Naked Objects provides default (but pluggable) bindings for various system aspects

visualization (obviously)persistence & transactionssecuritydistributionprogramming model semantics

The combination of Naked Objects and Together CC enable the DRY principle …

… and that in turn helps keeps things agile.Net and Java support provides pragmatic platform independence

MDA: Nice Principles, Shame about the ...

© 2004 Haywood Associates Ltd. 15

Agile MDA:Naked Objects &

Together Control Center

Agile MDA:Naked Objects &

Together Control Center

Dan HaywoodHaywood Associates Ltd.

[email protected]

Resourceshttp://blog.haywood-associates.co.uk/page/DanHaywoodhttp://www.nakedobjects.org/phpbb/index.phphttp://www.theserverside.com/articles/article.tss?l=NakedObjectSeries_1SPA2005 Conference, 10-13 April