Arquitectura de software dirigida por modelos (Model-Driven Architecture) Liliana Favre UNCPBA2006.

Post on 22-Jan-2016

221 views 0 download

Transcript of Arquitectura de software dirigida por modelos (Model-Driven Architecture) Liliana Favre UNCPBA2006.

Arquitectura de software Arquitectura de software dirigida por modelosdirigida por modelos(Model-Driven Architecture)(Model-Driven Architecture)

Liliana FavreLiliana FavreUNCPBAUNCPBA

20062006

Model-Driven Development Model-Driven Development

MDDMDD

Model-driven Development Model-driven Development (MDD)(MDD)

Un desarrollo MDD distingue al menos las siguientesUn desarrollo MDD distingue al menos las siguientesetapas:etapas: La construcción de un modelo del dominio, La construcción de un modelo del dominio,

denominado CIM, que expresa la lógica del negocio denominado CIM, que expresa la lógica del negocio desde una perspectiva independiente de la desde una perspectiva independiente de la computación.computación.

La construcción de un modelo, denominado PIM, La construcción de un modelo, denominado PIM, que expresa la funcionalidad del sistema en forma que expresa la funcionalidad del sistema en forma independiente de las características de plataformas independiente de las características de plataformas de implementación específicas.de implementación específicas.

La transformación de un PIM en uno o más modelos La transformación de un PIM en uno o más modelos en una plataforma específica, denominados PSM. en una plataforma específica, denominados PSM.

La transformación de modelos PSM a modelos de La transformación de modelos PSM a modelos de implementación, denominados ISM. implementación, denominados ISM.

MDD (Model-Driven Development)MDD (Model-Driven Development)

PIM

PSM

J2EE

PSM

REL

PSM

dotNET

CODECODE CODE

CIM

MDD- Modelos y MDD- Modelos y metamodelosmetamodelos

PIMMETAMODEL

PIMMODEL

PSM -.NETMETAMODEL

PSM-RELMETAMODEL

PSM-J2EEMETAMODEL

CODEMETAMODEL

CODEMETAMODEL

CODEMETAMODEL

PSM-J2EE

PSM-REL

PSM-.NET

CODE CODE CODE

Transformaciones y metamodelosTransformaciones y metamodelos

““es-instancia-de”es-instancia-de”

RefinamientoRefinamiento

PIM-PSMPIM-PSM

Refinamiento PIM-PIMmetamodeloRefinamiento PIM-PIMmetamodelo

PSM- PSMmetamodelo PSM- PSMmetamodelo

““es-instancia-de”es-instancia-de”PIMPIM

PSMPSM

MetamodeloMetamodelo

PIMPIM

MetamodeloMetamodelo

PSMPSM

Formalización de metamodelos MOF

Meta Object FacilityMeta Object FacilityMOFMOF

MOF captura la diversidad de estándares demodelamiento para integrar diferentes tipos demodelos y metadatos e intercambiarlos entrediferentes herramientas. UML 2.0 está alineado con MOF, es unainstancia de MOF. El núcleo de UML y de MOFcomparten los elementos de metamodelado. En UML 2.0 los conceptos de MOF y de UMLSuperstructure derivan de conceptos de UMLInfrastructure

MOFMOF

Las construcciones de modelamiento son un subconjuntodel núcleo de UML. Construcciones de modelamiento Clases, que modelan metaobjetos MOF. Asociaciones que modelan relaciones binarias entre

metaobjetos. Tipos de datos, que modelan tipos primitivos (Integer,

String,…) Packages, que modularizan los modelos.

Especificaciones en OCL Especificaciones en OCL Lenguaje naturalLenguaje natural

Limitaciones de los Limitaciones de los metamodelos MOFmetamodelos MOF

En MDDs, los diferentes lenguajes de modelado y deprogramación deben definirse en forma consistente yprecisa.La semántica de MOF está definida mediante UML/OCL: UML y OCL son imprecisos y ambiguos para

verificación, simulación y validación. Si bien OCL es un lenguaje textual su contexto

sintáctico está determinado gráficamente OCL no tiene el sólido background de los lenguajes

formales

Lenguajes formales Lenguajes formales versus OCLversus OCL

Lenguajes formales Sintaxis Semántica que describe los modelos asociados a la

especificación Sistema de inferencia que permite describir deducciones que

pueden hacerse desde la especificación formal

OCL El contexto sintáctico de OCL está determinado gráficamente. Semántica (notación matemática en un estilo de teoría de

conjuntos) No tiene cálculo de pruebas, deducción automatizada

Lenguajes formales versus Lenguajes formales versus OCLOCLOCL

Análisis sintáctico y de tipos. Validación dinámica de invariantes,

precondiciones y postcondiciones generando “instantáneas” de un modelo y comparándolas con el modelo especificado.

Deducciones lógicas Síntesis y verificación de código

Formalización de MOFFormalización de MOF

Para lograr un alto grado de automatización enPara lograr un alto grado de automatización enherramientas CASE la semántica de MOF herramientas CASE la semántica de MOF

debería serdebería serprecisaprecisa Automatizar Formalizar Automatizar Formalizar

Formalización de MOF

Diagramas estáticos UMLDiagramas estáticos UML OCLOCL

Formalización de MOFFormalización de MOF

En qué lenguaje?En qué lenguaje? Textual y formal.Textual y formal. Alineado a MOFAlineado a MOF

MDD involucra diferentes lenguajes de modelado

y de programación que deberían estar alineados

con MOF y definidos en forma precisa yconsistente.

Formalización de MOFFormalización de MOF

Interoperabilidad entre diferentes Interoperabilidad entre diferentes lenguajeslenguajes

formalesformalesMetamodelos MOF Leng.Formales

Leng.Programación

LenguajeFormalintermedio

Transformaciones automáticas

El lenguaje NEREUSEl lenguaje NEREUS

El lenguaje de El lenguaje de metamodeladometamodelado

NEREUSNEREUS NEREUSNEREUS es un lenguaje para es un lenguaje para

especificar metamodelos basados especificar metamodelos basados en MOF.en MOF.

NEREUSNEREUS es un intermediario es un intermediario entre metamodelos MOF y entre metamodelos MOF y variedad de lenguajes formales y variedad de lenguajes formales y de programación.de programación.

Las relaciones en Las relaciones en NEREUSNEREUS son son entidades de primera clase. entidades de primera clase.

El lenguaje de El lenguaje de metamodeladometamodelado

NEREUSNEREUSConstrucciones NEREUS CLASES ASOCIACIONES PACKAGES Tipos de datos

Tipos predefinidos: OCL Collection, tuple, enumerated,…

Tipos constructores para associations

NEREUSNEREUSSINTAXISSINTAXIS

CLASS className [<parameterList>]IMPORTS <importsList>INHERITS<inheritsList>IS-SUBTYPE-OF <subtypeList>ASSOCIATES<associatesList>DEFERREDTYPES <typesList>FUNCTIONS <functionList>EFFECTIVETYPES <typesList>FUNCTIONS <functionList>AXIOMS <varList><axiomList>END-CLASS

NEREUSNEREUSSintaxisSintaxis

CLASS Collection [Elem]IMPORTS Boolean, Nat GENERATED-BY create, addDEFERREDTYPES CollectionFUNCTIONS create : Collectionadd : Collection x Elem Collectioncount : Collection x Elem Natiterate : Collection x (Elem x Acc: ANY) x ( -> Acc ) -> Acc EFFECTIVEFUNCTIONSisEmpty: Collection ->Booleansize: Collection Nat

NEREUSNEREUSSintaxisSintaxis

EFFECTIVEFUNCTIONSisEmpty: Collection ->Booleansize: Collection Nat includes: Collection x Elem ->Boolean includesAll: Collection x Collection ->Booleanexcludes: Collection x Elem -> BooleanforAll : Collection X (Elem->Boolean) ->Boolean exists : CollectionX(Elem->Boolean) ->Boolean select: Collection X (Elem->Boolean) -> Collection

NEREUSNEREUSSintaxisSintaxis

AXIOMS c: Collection; e : Elem; f: Elem->Boolean; g: Elem x Acc-> Acc; base : -> AccisEmpty ( c ) = (size (c ) = 0 )iterate (create, g, base ) = baseiterate (add (c, e), g, base)= g (e, iterate (c, g, base))count (c,e) = LET FUNCTIONS f1: Elem x Nat ->Nat AXIOMS e1:Elem; i:Nat f1(e1, i) = if e = e1 then i+1 else i IN iterate (c, f1, 0) END-LET

NEREUSNEREUSSintaxisSintaxis

AXIOMS c: Collection; e : Elem; f: Elem->Boolean; g: Elem x Acc-> Acc; base : -> Acc…includes (create , e ) = Falseincludes (add (c, e), e1) = if e = e1 then True else includes (c, e1) forAll (create , f ) = TrueforAll (add(c,e), f ) = f (e) and forAll (c, f) exists (create, f ) = Falseexists (add (c, e)) = f (e) or exists (c, f ) select (create, f) = createselect (add (c,e), f) = if f(e) then add (select(c,f ),e) else select (c, f)… END-CLASS

NEREUSNEREUSSintaxisSintaxis

AXIOMS c: Collection; e : Elem; f: Elem->Boolean; g: Elem x Acc-> Acc; base : -> Acc…includes (create , e ) = Falseincludes (add (c, e), e1) = if e = e1 then True else includes (c, e1) forAll (create , f ) = TrueforAll (add(c,e), f ) = f (e) and forAll (c, f) exists (create, f ) = Falseexists (add (c, e)) = f (e) or exists (c, f ) select (create, f) = createselect (add (c,e), f) = if f(e) then add (select(c,f ),e) else select (c, f)… END-CLASS

NEREUS: NEREUS: La jerarquía AssociationLa jerarquía Association

Association

Aggregation

Shared

Non-Shared

Bidirectional

... Binary Association

Unidirectional

1..1 *..*

NEREUS NEREUS Especificación de Especificación de

asociacionesasociaciones

ASSOCIATIONASSOCIATION <relationName> <relationName>

ISIS <constructorTypeName>[...:Class1;...:Class2;<constructorTypeName>[...:Class1;...:Class2;

...:Role1;...:Role2; ...: mult1; ...: ...:Role1;...:Role2; ...: mult1; ...: mult2; ...:visibility1; ...:visibility2]mult2; ...:visibility1; ...:visibility2]

CONSTRAINED BYCONSTRAINED BY <constraintList> <constraintList>

ENDEND

CLASS C_PackageASSOCIATES

<<Class_Package>>,...

Especificación de asociacionesEspecificación de asociacionesEjemploEjemplo

associationEnd

AssociationEnd

name:String upperbound: Int lowerbound: Int

* *

Class

name:String

source

1

* 1

other End

Parents

Association

name:String

Package

name:String

1 target

*

2 1

*

association

owner 1

owner * 1

nestedpackages * 0..1

Interface 0..* 0..*

NEREUS NEREUS Especificación de Especificación de

asociacionesasociacionesCLASS C_PackageASSOCIATES <<Class_Package>>,...

ASSOCIATION Class_PackageIS Bidirectional-1 [C_Class: class1; C_Package:

class2;class: role1; owner: role2; *: mult1; 1: mult2; +:

visibility1;+:v isibility2]CONSTRAINED BY…END

NEREUS NEREUS PackagePackage

PACKAGEPACKAGE packageName packageName

IMPORTSIMPORTS < importList> < importList>

INHERITSINHERITS < inheritList> < inheritList>

<elements><elements>

END-PACKAGEEND-PACKAGE

NEREUSNEREUSPackage CorePackage Core

PACKAGE CoreCLASS C_ClassASSOCIATES<<A_parents>>, <<Class_Package>>, <<A-allParents>>, <<A_source>>, <<A_target>>,…FUNCTIONSname: C_Class -> String…END-CLASSCLASS C_PackageASSOCIATES<<Association_Package>>,<<Class_Package>>,<<A_allNested>,<<A_ownerPack>> FUNCTIONS name: C_Package -> String… END-CLASS

NEREUSNEREUSPackage CorePackage Core

CLASS C_Association…CLASS C_AssociationEnd…CLASS InterfaceASSOCIATION A_parentsIS Unidirectional-2[C_Class:class1; C_Class:class2; class:role1;

parents:role2; 1:mult1; *:mult2; +:visibility1; +: visibility2]ENDASSOCIATION A_target…ASSOCIATION Class_PackageIS Bidirectional-1 [C_Class: class1; C_Package:class2; class:role1; owner:role2; *:mult1; 1:mult2;+:visibility1;+::visibility2]…END-PACKAGE

NEREUSNEREUSPackage CorePackage Core

CLASS C_Association…CLASS C_AssociationEnd…CLASS InterfaceASSOCIATION A_parentsIS Unidirectional-2[C_Class:class1; C_Class:class2; class:role1;

parents:role2; 1:mult1; *:mult2; +:visibility1; +: visibility2]ENDASSOCIATION A_target…ASSOCIATION Class_PackageIS Bidirectional-1 [C_Class: class1; C_Package:class2; class:role1; owner:role2; *:mult1; 1:mult2;+:visibility1;+::visibility2]…END-PACKAGE

Nereus, el lenguaje Nereus, el lenguaje intermediointermedio

Metamodelos MOFLeng.Formales

Leng.ProgramaciónNEREUS

Ejemplo Ejemplo Package Person&MeetingPackage Person&Meeting

Person

name:String

Affiliation:String

Address:String

numMeeting:Nat

numConfirmedMeeting ():Nat

Meeting

title:String

start:String

end:String

isConfirmed:Boolean

duration(): Time

checkDate (): Bool

cancel()

numConfirmedParticipants():Nat

Participates

2..* * participants meetings

Hussmann, H. et al. Abstract Data Types and UML, Report DISI-TR-99-15

P&M

OCL Specifications: OCL Specifications: Person&MeetingPerson&Meeting

context Person:: numMeeting ( ): Natpost: result = self.meetings -> sizecontext Meeting :: isConfirmed (): Boolpost: result = self.checkDate() and self.numConfirmedParticipants >= 2context Meeting:: checkDate():Boolpost: result = self.participants->collect(meetings) -> forAll(m | m<> self and m.isConfirmed implies

(after(self.end,m.start) or after(m.end,self.start)))context Person :: numMeetingConfirmed ( ) : Natpost: result= self.meetings -> select (isConfirmed) -> size

context Meeting :: duration ( ) : Timepost: result = timeDifference (self.end, self.start)

P&M en NEREUSP&M en NEREUSPACKAGE PACKAGE P&MP&MCLASSCLASS PersonPersonIMPORTSIMPORTS String, NatString, NatASSOCIATESASSOCIATES << <<Participates>>Participates>>GENERATED-BYGENERATED-BY Create_Person Create_PersonEFFECTIVEEFFECTIVETYPETYPE Person PersonFUNCTIONSFUNCTIONScreatePerson: createPerson: String x String x String -> Person String x String x String -> Person name: Person -> Stringname: Person -> Stringaffiliation: Person -> Stringaffiliation: Person -> Stringaddress: Person -> Stringaddress: Person -> Stringset-name: Person x String -> Personset-name: Person x String -> Personset-affiliation : set-affiliation : Person x String -> PersonPerson x String -> Personset-address: Person x String -> Personset-address: Person x String -> Person

AXIOMS p:Person; m: Meeting; s,AXIOMS p:Person; m: Meeting; s,

s1, s2, s3: String; pa: Participatess1, s2, s3: String; pa: Participates

name(createPerson(s1,s2, s3)) = s1name(createPerson(s1,s2, s3)) = s1

affiliation (createPerson (s1, s2, s3) ) = s2affiliation (createPerson (s1, s2, s3) ) = s2

address (createPerson (s1, s2, s3)) = s3address (createPerson (s1, s2, s3)) = s3

set-name ( createPerson (s1, s2, s3), s) = set-name ( createPerson (s1, s2, s3), s) =

createPerson (s,s2,s3)) createPerson (s,s2,s3))

set-affiliation (createPerson( s1,s2, s3), s) = set-affiliation (createPerson( s1,s2, s3), s) = createPerson (s1, s, s3)) createPerson (s1, s, s3))

numConfirmedMeetings (p) = numConfirmedMeetings (p) = size(selectsize(selectmm getMeetings(Participates,p), getMeetings(Participates,p),

[isConfirmed (m)]) [isConfirmed (m)])

numMeetings (p)= numMeetings (p)= size (getMeetings (Participates, p))size (getMeetings (Participates, p)) ……

END-CLASS END-CLASS

P&M en NEREUSP&M en NEREUSCLASSCLASS Meeting MeetingIMPORTSIMPORTS String, Date, Boolean, Time String, Date, Boolean, TimeASSOCIATESASSOCIATES << <<ParticipatesParticipates>>>>EFFECTIVEEFFECTIVETYPETYPE MeetingMeetingGENERATED-BY GENERATED-BY createMeetingcreateMeetingFUNCTIONSFUNCTIONScreateMeeting: createMeeting: String x Date x Date x Boolean- >MeetingString x Date x Date x Boolean- >Meetingtittle: Meeting -> Stringtittle: Meeting -> Stringstart : Meeting -> Datestart : Meeting -> Dateend : Meeting -> Dateend : Meeting -> DateisConfirmed : Meeting -> BooleanisConfirmed : Meeting -> Booleanset-tittle: Meeting x String -> Meetingset-tittle: Meeting x String -> Meetingset-start : Meeting x Date -> Meetingset-start : Meeting x Date -> Meetingset-end: Meeting x Date -> Meetingset-end: Meeting x Date -> Meetingset-isConfirmed: set-isConfirmed: Meeting x Boolean -> BooleanMeeting x Boolean -> Boolean

AXIOMS s: String; d, d1,: Date; AXIOMS s: String; d, d1,: Date;

b: Boolean;…b: Boolean;…

title( createMeeting (s, d, d1, b) ) = stitle( createMeeting (s, d, d1, b) ) = s

start ( createMeeting (s, d, d1, b)) = dstart ( createMeeting (s, d, d1, b)) = d

end ( createMeeting (s, d, d1, b)) = d1end ( createMeeting (s, d, d1, b)) = d1

isConfirmed(createMeeting(s,d,d1,b)) = bisConfirmed(createMeeting(s,d,d1,b)) = b

......

END-CLASSEND-CLASS

ASSOCIATIONASSOCIATION Participates Participates

ISIS Bidirectional-Set [Person: Class1; Bidirectional-Set [Person: Class1; Meeting: Class2; participants: Role1; Meeting: Class2; participants: Role1; meetings: Role2; *: Mult1; * : Mult2; meetings: Role2; *: Mult1; * : Mult2; + : Visibility1; +: Visibility2]+ : Visibility1; +: Visibility2]

ENDEND

END-PACKAGEEND-PACKAGE

Ejemplo P&MEjemplo P&MAsociación Bidirectional-SetAsociación Bidirectional-Set

RELATION SCHEME Bidirectional-Set INHERITS BinaryAssociation [Class1 ->Person, Class2->Meeting] IMPORTS Set_Person: Set [Person], Set_Meeting: Set[Meeting]EFFECTIVEFUNCTIONS name, frozen , changeable , addOnly , getRole1, getRole2,

getMult1, getMult2, getVisibility1, getVisibility2, isRelated, isEmpty, rightCardinality, leftCardinality

create: Typename->ParticipatesaddLink:Participates(b) x Person(p) x Meeting(m)-> Participates pre: not isRelated(a,p,m)isRightLinked: Participates x Person -> BooleanisLeftLinked: Participates x Meeting -> BooleangetMeetings: Participates(a) x Person(p) -> Set_Meeting pre: isRightLinked(a,p)getParticipants: Participates(a) x Meeting(m)-> Set_Person pre: isLeftLinked(a,m)remove: Participates (a) x Person (p) x Meeting (m) -> Participates pre: isRelated(a,p,m)

Ejemplo P&MEjemplo P&MAsociación Bidirectional-SetAsociación Bidirectional-Set

AXIOMS a:Participates; p,p1: Person; m,m1:Meeting; t:TypeName

name(create(t))= t name(add(a,p,m)) = name(a)isEmpty (create(t))= True isEmpty(addLink(a,p,m))= Falsefrozen (a) = False changeable (a)= True addOnly (a) = FalsegetRole1(a) = “ participants” getRole2 (a) = “meetings”getMult1(a) = * getMult2(a) = *getVisibility1(a) = + getVisibility2(a) = +

Ejemplo P&MEjemplo P&MAsociación Bidirectional-SetAsociación Bidirectional-Set

isRelated (create(t),p,m) = FalseisRelated(addLink(a,p,m),p1,m1) = (p=p1 and m=m1) or isRelated (a,p1,m1) isRightLinked (create(t),p) = FalseisRightLinked (addLink (a,p,m),p1)= if p=p1 then True else isRightLinked(a,p1)rightCardinality(create(t),p)= 0rightCardinality(addLink(a,p,m),p1) = if p=p1 then 1 + rightCardinality(a,p1)else rightCardinality(a,p1)getMeetings(addLink(a,p,m),p1)= if p=p1 then including (getMeetings(a,p1), m)else getMeetings(a,p1)getParticipants (addLink (a,p,m),m1) = if m=m1 then including (getParticipants(a,m1) , m) else

getParticipants(a,m1) END-RELATION

Traducción de metamodelos MOFTraducción de metamodelos MOF

Formalizando modelos Formalizando modelos estáticos UML.Traducción estáticos UML.Traducción

de Packagesde Packages

Package UML GS NEREUS

Traducción de interfaces

Traducción de OCL

Traducción de relaciones

Esquemas Comp. Reusables Association Reglas Transformación

OCL/NEREUS

Nereus Nereus

Esquemas (BOX_, ASSOCIATION_)

Formalizando modelos Formalizando modelos estáticos UML. El esquema estáticos UML. El esquema

BOXBOXCLASS CLASS NameNameIMPORTSIMPORTS TP1,..., TPm, T-attr1, T-attr2,..., TattrnTP1,..., TPm, T-attr1, T-attr2,..., TattrnINHERITSINHERITS B1,B2,..., BmB1,B2,..., BmASSOCIATES ASSOCIATES <<<<Aggregation-E1>>,...,<<Aggregation-Em>>,Aggregation-E1>>,...,<<Aggregation-Em>>,<< Composition-C1>>,...,<<Composition-Ck>>,<< Composition-C1>>,...,<<Composition-Ck>>,<< Association-D1>>,...,<<Association-Dk>><< Association-D1>>,...,<<Association-Dk>>EFFECTIVEEFFECTIVETYPETYPE NameNameFUNCTIONSFUNCTIONScreateName : createName : T-attr1T-attr1 x ... x x ... x T-attrnT-attrn -> -> NameNamesetseti i : : NameName x x T-attri T-attri -> -> NameName

getgetii: : Name Name -> -> T-attri T-attri 1<=i<=n 1<=i<=n

Formalizando modelos Formalizando modelos estáticos UML. El esquema estáticos UML. El esquema

BOXBOXDEFERREDFUNCTIONSmeth1: Name x TPi1 x TPi2 x TPin -> TPij...methr : Name x TPr1 x TPr2 ... x TPin -> TPijAXIOMS t1,t1’: T-attr1; t2,t2’:T-attr2;...;

tn,tn’:T-attrngeti(create(t1,t2,...,tn)) = ti 1 i n seti (create (t1,t2,...,tn), ti’) = create

(t1,t2,...ti’,...,tn) END-CLASS

Formalizando modelos Formalizando modelos estáticos UML. El esquema estáticos UML. El esquema

AssociationAssociation

ASSOCIATION ___IS __ [__: Class1; __:Class2; __: Role1;__:Role2;__:Mult1; __:Mult2; __:Visibility1;

__:Visibility2]CONSTRAINED BY __END

Un puente entre UML/OCL Un puente entre UML/OCL y NEREUSy NEREUS

Un sistema de reglas de Un sistema de reglas de transformacióntransformación

para traducirpara traducir Tipos OCL predefinidos Tipos OCL predefinidos Expresiones básicas OCL Expresiones básicas OCL PrecondicionesPrecondiciones PostcondicionesPostcondiciones InvariantesInvariantes Constraints de asociacionesConstraints de asociaciones

Reglas OCL/NEREUSReglas OCL/NEREUS

v. operation(v’) v->operation (v’) operation (v,v’) v.attribute attribute (v )context A object.rolename getRolename (A, object)e.op op (Translate NEREUS (e))collection-> op (v:Elem |b-expr-with-v)op ::=select| forAll| reject| exists LET

FUNCTIONS f: Elem ->Boolean AXIOMS v : Elem

f(v)= TranslateNEREUS (b-expr-with-v )IN op (collection, f)END-LET----------------------------------------------

opv(collection,[f(v)]) concise notationT Op (parameterList):ReturnTypepost: expr AXIOMS t : T, ...

TranslateNEREUS (exp)

OCL NEREUS

Reglas OCL/NEREUSReglas OCL/NEREUS

collection Op (parameterList): Boolean post: result = collection forAll (elem: Elem boolean-expression-with-elem ) FUNCTIONS TranslateNEREUS (collection Op (parameterList): Boolean ) AXIOMS c: Collection; e: Elem; f: Elem->Boolean… Op (create, parameterList) = TRUE Op (add (c,e), parameterList) = Op(c, parameterList) AND TranslateNEREUS (boolean-expression-with-elem ) with[ elem |-> e]

Reglas OCL/NEREUSReglas OCL/NEREUS

collection Op (parameterList) : Boolean

post: result = collection exists (elem: Elem boolean-expression-with-elem) FUNCTIONS TranslateNEREUS(collection Op (parameterList) : Boolean ) AXIOMS c: Collection,; e: Elem; f: Elem->Boolean… Op (create, parameterList)= FALSE Op (add(c,e), parameterList) = Op (c,parameterList) OR TranslateNEREUS (boolean-expression-with-elem) with[ elem |-> e]

Reglas OCL/NEREUSReglas OCL/NEREUS

sequence Op (parameterList) : Boolean post: result = Sequence { 1 ..sequence size } forAll (index: Integer boolean-expr-with-index)

FUNCTIONS TranslateNEREUS (sequence Op (parameterList) : Boolean) AXIOMS s : Sequence; index:Nat; ... Op (s, parameterList) = ( 1 index size(s) ) TranslateNEREUS (boolean-expr-with-index )

Reglas OCL/NEREUSReglas OCL/NEREUS

collection -> Oper (t1:T1; t2: T2;...): Boolean post: result = collection -> iterate (elem:Elem; acc: Boolean = exp | <boolean-exp-with-elem-and-acc>) FUNCTIONS TranslateNEREUS (collection -> Oper (t1:T1; t2: T2;...): Boolean) ...

AXIOMS c: Collection; e: Elem; t1:T1; t2:T2,… Oper (create, t1,t2,.. ) = TranslateNEREUS (exp) Oper (add (c,e), t1, t2,.....) = TranslateNEREUS (boolean-expression-with-elem-and acc)

with [elem | e; acc |-> Op (c, t1, t2,...)]

Reglas OCL/NEREUSReglas OCL/NEREUS

collection -> Op (t1:T1; t2: T2;...): ReturnType post: result = collection -> iterate (elem: Elem; acc:Type = expr | expr-with-elem-and-acc) FUNCTIONS Translate NEREUS (collection -> Op (t1:T1; t2: T2;...): ReturnType) ...

AXIOMS c: Collection; e: Elem; t1:T1; t2:T2,… LET FUNCTIONS g : Elem x Type -> Type base : -> Type AXIOMS c: Collection; e: Elem; t1:T1; t2:T2,… g (e,acc) = Translate NEREUS ( expr -with-elem-and-acc) base = Translate NEREUS ( expr) IN Oper (c,t1,t2,…) = iterate (c,g, base)

Reglas OCL/NEREUSReglas OCL/NEREUS

T Op (parameterList) : Return Type post: T.allInstances forAll (elem: Elem boolean-expr-with-elem ) FUNCTIONS TranslateNEREUS (T Op (parameterList) : Return Type ) AXIOMS t : T; e:Elem;... TranslateNEREUS (boolean-expr-with-elem)

with elem|-> e

Desde OCL a NEREUS Desde OCL a NEREUS Traducción de una Traducción de una

postcondiciónpostcondicióncontext Person :: numMeetingConfirmed ( ) : Nat OCLpost: result= self.meetings -> select (isConfirmed) -> size

T Op (parameterList) : ReturnType post: result = expr  

AXIOMS t:T, ... Op (t, parameterList) = TranslateNEREUS (expr)

T-> select (v :Type | boolean-expr-with-v)

  selectv (TranslateNEREUS (T), TranslateNEREUS (boolean-expr-with-v)

NEREUSAXIOMS p:Person; m:Meeting;Pa:Participates;…numMeetingsConfirmed (p) = size(selectm (getMeetings(Pa,p), isConfirmed [m])

RULE 2

RULE 1

RULES 1,2,..

Traducción de P&M a Traducción de P&M a NEREUSNEREUS

UML NEREUS Person&Meeting Person & Meeting

Traducción de interfaz: Person y Meeting

Traducción OCL:Person y Meeting

Traducción de Participates

Esquemas reusables (BOX_Person, Box-Meeting)

Esquema Componente Bidirectional-Set. Association

Sistema Transf. OCL

NEREUS NEREUS

Traducción de P&M a Traducción de P&M a NEREUSNEREUS

1.1. Generar una especificación parcial de Generar una especificación parcial de PersonPerson y y MeetingMeeting a partir de la instanciación de a partir de la instanciación de BOX.BOX.

2.2. Generar una especificación de Generar una especificación de ParticipatesParticipates instanciando el esquema instanciando el esquema Association.Association.

3.3. Transformar especificaciones OCL a partir del Transformar especificaciones OCL a partir del sistema de transformaciones.sistema de transformaciones.

4.4. Generar el Generar el Package P&M Package P&M que incluye a las clases que incluye a las clases PersonPerson y y Meeting Meeting y una asociación, y una asociación, Participates.Participates.

Traducción de P&M a Traducción de P&M a NEREUSNEREUS

La clase PersonLa clase PersonCLASS PersonIMPORTS String, NatASSOCIATES <<Participates>>GENERATED-BY create_PersonDEFERREDTYPES Person FUNCTIONS create_Person: String x _-> PersonEFFECTIVEFUNCTIONS name: Person -> StringnumMeetings: Person -> Nat numConfirmedMeeting: Person -> Natset-name: Person x String -> Personset-numMeetings: Person x Nat -> Personset-numConfirmedMeeting: Person x Nat -> PersonAXIOMS p:Person; m:Meeting; s,s’: Stringname(create_Person(s))= sset-name(create_Person(s), s’) = create_Person (s’)END-CLASS

PASO 1

Traducción de P&M a Traducción de P&M a NEREUSNEREUS

La clase MeetingLa clase MeetingCLASS MeetingIMPORTS String, Date, Boolean, TimeASSOCIATES <<Participates>> GENERATED-BY create_MeetingDEFERREDTYPES MeetingFUNCTIONS create_Meeting: String x Date x Date x Boolean -> MeetingEFFECTIVEisConfirmed: Meeting -> Boolean ……AXIOMS s, s’:String; d, d’, d1, d1’:Date; b, b’:BooleanAXIOMS s, s’:String; d, d’, d1, d1’:Date; b, b’:Booleantitle (create_Meeting (s,d,d1,b)) = stitle (create_Meeting (s,d,d1,b)) = sstart (create_Meeting (s,d,d1,b)) = dstart (create_Meeting (s,d,d1,b)) = dend (create_Meeting (s,d,d1,b)) = d1end (create_Meeting (s,d,d1,b)) = d1set-tittle (create_Meeting (s,d,d1,b),s’) = create_Meeting (s’,d,d1,b)set-tittle (create_Meeting (s,d,d1,b),s’) = create_Meeting (s’,d,d1,b)set-start(create_Meeting (s,d,d1,b),d’) = create_Meeting (s,d’,d1,b)set-start(create_Meeting (s,d,d1,b),d’) = create_Meeting (s,d’,d1,b)set-end(create_Meeting (s,d,d1,b),d1’) = create_Meeting (s,d,d1’,b)set-end(create_Meeting (s,d,d1,b),d1’) = create_Meeting (s,d,d1’,b)END-CLASSEND-CLASS

Traducción de P&M a Traducción de P&M a NEREUSNEREUS

La asociación La asociación ParticipatesParticipatesASSOCIATION ParticipatesIS Bidirectional-Set [ Person: Class1; Meeting: Class2; participants: Role1; meetings:Role2; *:Mult1; *: Mult2; +: Visibility1;+: Visibility2]END

RELATION SCHEME Bidirectional-Set --Bidirectional /* to */ as SetIS-SUBTYPE-OF BinaryAssociation [Person:Class1;

Meeting:Class2] ……

Traducción de P&M a Traducción de P&M a NEREUSNEREUS

La clase PersonLa clase PersonCLASSCLASS Person PersonIMPORTSIMPORTS String, Nat String, NatASSOCIATESASSOCIATES <<Participates>> <<Participates>> GENERATED-BYGENERATED-BY create_Person create_Person......AXIOMS p: Person; s, s’: String; Pa: ParticipatesAXIOMS p: Person; s, s’: String; Pa: Participatesname (create_Person(s)) = sname (create_Person(s)) = sset-name (create_Person(s), s’) = create_Person(s’)set-name (create_Person(s), s’) = create_Person(s’)numConfirmedMeetings (p) = numConfirmedMeetings (p) = size(selectm (getMeetings(Pa,p), [isConfirmed (m)] ) size(selectm (getMeetings(Pa,p), [isConfirmed (m)] )

Reglas Reglas 10,1510,15

numMeetings (p) = size (getMeetings (Pa, p)) numMeetings (p) = size (getMeetings (Pa, p)) Reglas 10Reglas 10

END-CLASSEND-CLASS

PASO 3

Traducción de P&M a Traducción de P&M a NEREUSNEREUS

La clase MeetingLa clase MeetingCLASSCLASS MeetingMeetingAXIOMS m,m1:Meeting; s,s’:String; d,d’,d1,d1’:Date; Pa:Participates;…AXIOMS m,m1:Meeting; s,s’:String; d,d’,d1,d1’:Date; Pa:Participates;…title (create_Meeting(s,d,d1,b)) = stitle (create_Meeting(s,d,d1,b)) = sstart (create_Meeting(s,d,d1,b)) = dstart (create_Meeting(s,d,d1,b)) = dend (create_Meeting(s,d,d1,b)) = d1end (create_Meeting(s,d,d1,b)) = d1set-tittle (create_Meeting(s,d,d1,b),s’) = create_Meeting(s’,d,d1,b)set-tittle (create_Meeting(s,d,d1,b),s’) = create_Meeting(s’,d,d1,b)set-start(create_Meeting(s,d,d1,b),d’) = create_Meeting(s,d’,d1,b)set-start(create_Meeting(s,d,d1,b),d’) = create_Meeting(s,d’,d1,b)set-end(create_Meeting(s,d,d1,b),d1’) = create_Meeting(s,d,d1’,b)set-end(create_Meeting(s,d,d1,b),d1’) = create_Meeting(s,d,d1’,b)duration (m) = timeDifference (end(m),start(m)) duration (m) = timeDifference (end(m),start(m)) Regla 10Regla 10isConfirmed (cancel(m)) = FalseisConfirmed (cancel(m)) = FalseisConfirmed (m)=checkDate(m) and NumConfirmedParticipants (m) >= 2 isConfirmed (m)=checkDate(m) and NumConfirmedParticipants (m) >= 2 checkDate(m) = forAllcheckDate(m) = forAllmeme(collect(collectpp(getParticipants(Pa,m), (getParticipants(Pa,m), [getMeetings (Pa, p)]), [consistent(m,me)] ) [getMeetings (Pa, p)]), [consistent(m,me)] )

consistent(m,m1)= not (isConfirmed(m1)) consistent(m,m1)= not (isConfirmed(m1)) Reglas 10,15,16Reglas 10,15,16or (end(m)<start(m1) or end(m1)<start(m))or (end(m)<start(m1) or end(m1)<start(m)) NumConfirmedParticipants (m) = size (getParticipants(Pa,m)) NumConfirmedParticipants (m) = size (getParticipants(Pa,m)) END-CLASSEND-CLASS

Traducción de NEREUS a LOOTraducción de NEREUS a LOO

Desde NEREUS a EIFFELDesde NEREUS a EIFFEL

NEREUS EIFFEL

Traducción de clases y asociaciones

Construcción contratos/ implementaciones

EIFFEL

Esquemas Reusable Association Heurísticas Heurísticas Contratos Impl. Heuristics Heuristics.

Traducción de clasesTraducción de clases

CLASSCLASS Name [ Name [<parameterList><parameterList>] ] clase Eiffelclase EiffelIMPORTSIMPORTS <importsList><importsList> relación clienterelación cliente

IS-SUBTYPE-OFIS-SUBTYPE-OF <subtypeList><subtypeList>INHERITSINHERITS <inheritsList><inheritsList> herenciaherencia DEFERREDDEFERREDTYPES TYPES <sortList> <sortList> FUNCTIONSFUNCTIONS <functionList> <functionList> feature diferidos feature diferidos

precondicionesprecondiciones

EFFECTIVEEFFECTIVETYPES TYPES <sortList> <sortList> FUNCTIONS FUNCTIONS <functionList> <functionList> feature efectivo feature efectivo precondicionesprecondiciones

AXIOMSAXIOMS <varList> <axiomsList> <varList> <axiomsList> postcondiciones postcondiciones

invariantesinvariantesEND-CLASSEND-CLASS

Generación de contratos EIFFEL

Transformación de precondicionesTransformación de precondiciones

Transformación de axiomasTransformación de axiomas

Heurística para generar invariantesHeurística para generar invariantesHeurística para generar postcondicionesHeurística para generar postcondicionesHeurística para generar implementacionesHeurística para generar implementaciones

Construcción de invariantesConstrucción de invariantes

Heurística Heurística Identificar correspondencias entre los términosIdentificar correspondencias entre los términosde un axioma y los “features” de una clase que sólode un axioma y los “features” de una clase que sólodependan del estado actual del objeto.dependan del estado actual del objeto.

Un axioma puede traducirse a un invariante siUn axioma puede traducirse a un invariante silos únicos subtérminos del “tipo de interés” quelos únicos subtérminos del “tipo de interés” queexisten son variables.existen son variables.

Construcción de invariantesConstrucción de invariantesUn ejemploUn ejemplo

CLASSCLASS BSTACK BSTACK G G ........EFFECTIVEEFFECTIVETYPESTYPES BSTACK BSTACKFUNCTIONScapacity:BSTACKcapacity:BSTACK Integer Integercount: BSTACKcount: BSTACK Integer Integerfull: BSTACKfull: BSTACK Boolean Booleanempty:BSTACK empty:BSTACK Boolean Boolean............AXIOMS s: BSTACK; s: GAXIOMS s: BSTACK; s: Gfull(s) full(s) (capacity(s) = count(s) ) (capacity(s) = count(s) )empty(s)empty(s) (count(s)=o) (count(s)=o) END-CLASSEND-CLASS

class class BSTACKBSTACKGG..........

capacity:INTEGER ....capacity:INTEGER ....count:INTEGER...count:INTEGER...full:BOOLEAN...full:BOOLEAN...empty:BOOLEAN... empty:BOOLEAN... invariantinvariantfull= (count=capacity); full= (count=capacity); empty= (count =0)empty= (count =0) ..........endend

Construcción de postcondicionesConstrucción de postcondiciones

HeurísticaHeurísticaIdentificar en un axioma un término Identificar en un axioma un término op(<lista-de-variables>) op(<lista-de-variables>) donde donde opop es el nombre de una es el nombre de una

operación y operación y <lista-devariables><lista-devariables> contiene una variable del contiene una variable del tipo de interés y todos los restantes términos dependen tipo de interés y todos los restantes términos dependen solamente de constantes o las restantes variables de solamente de constantes o las restantes variables de <lista-de-variables> <lista-de-variables>

Si op(<lista-de-variables>) Si op(<lista-de-variables>) es un término del “tipo de es un término del “tipo de interés” se lo asocia ainterés” se lo asocia a Current Current y la variable del “tipo de y la variable del “tipo de interés” ainterés” a old old

Si op(<lista-de-variables>) Si op(<lista-de-variables>) nono es un término del tipo de es un término del tipo de interés se lo asocia ainterés se lo asocia a Result Result

Construcción de postcondiciones:Construcción de postcondiciones:Un ejemploUn ejemplo

CLASSCLASS SETSETGG......EFFECTIVEEFFECTIVETYPESTYPES SET SETFUNCTIONSFUNCTIONShas: SET x G has: SET x G BOOLEAN BOOLEANcount: SETcount: SET INTEGER INTEGERextend: SET x G extend: SET x G SET SETempty: SET empty: SET BOOLEAN BOOLEANAXIOMS s:SET; v:GAXIOMS s:SET; v:Ghas(s,v)has(s,v)not empty(s)not empty(s)count(extend(count(extend(ss,v)) = ,v)) = if has(if has(ss,v) then count(,v) then count(ss) ) else plus(count(else plus(count(ss) ,1) ) ,1) END-CLASSEND-CLASS

class SETclass SETGG........empty:BOOLEANempty:BOOLEAN  has(v:G):BOOLEANhas(v:G):BOOLEAN..............ensureensureResult Result impliesimplies not empty not empty............extend( v: G)extend( v: G).................. .................. ensureensureoldold has(v) has(v) impliesimplies count= count=oldold countcountnot not oldold has(v) has(v) Implies Implies (count=(count=old old count + 1)count + 1)

Traducción de asociacionesTraducción de asociacionesEl componente AssociationEl componente Association

Realization level

Implementation level

Figure 4. The component Association

...

... ... ...

...

Association

Whole- Part Binary Association Qualified Association

Aggregation Composition Unidirect. Bidirect.

1..1 *..* ...

*..*

Hash- Table

File-T Array-T Linked-T

Seq- Table Tree- Table

Scheme 1 Scheme 2 Scheme i

EIFFEL

Traducción de asociacionesTraducción de asociacionesP&MP&M

class Class1 ... feature {NONE} -- data members for association Association_Name rol2: UnboundedCollectionbyReference [Class2]; mult_rol1: MULTIPLICITY; -- operations for association Association_Name get_mult_rol2 : MULTIPLICITY is do Result:= mult_rol2 end; get_frozen_rol2 : BOOLEAN is do Result:= result_frozen1 end; add_only_rol2 : BOOLEAN is do Result:= result_add_only1 end;

Traducción de asociacionesTraducción de asociacionesP&MP&M

changeable_rol2 : BOOLEAN is do Result:= result_changeable1 end; cardinality_rol2 : INTEGER is do Result:= rol2.count end; set_ rol2 ( d:UnboundedCollectionbyReference [Class2]) is require get_mult_rol2.get_upper_bound >= d.count do rol2 := d end; get_ rol2 : UnboundedCollectionbyReference[Class2] is do Result := rol2 end; remove_rol2 (e: Class2) is require is-related_rol2 (e) and not get_frozen_rol2 and not add-only_rol2 do rol2. prune (e) end;

Traducción de asociacionesTraducción de asociacionesP&MP&M

add_rol2 (e: Class2) is require is-related_rol2 (e) and not get_frozen_rol2 cardinality_rol2get_mult_rol2.get_upper_bound do rol2. put (e) end; add_rol2 (e:Class2) is require is-related_rol2 (e) and multiplicity_rol2get_mult_rol2.get_upper_bound and not get_frozen_rol2 do rol2. put (e) end; is_related_rol2 (e: Class2): BOOLEAN is do Result:=rol2. has (e) end; invariant mult_ rol2.get_lower_bound = LowerBound; mult_ rol2.get_upper_bound = Upper Bound; rol2.count >= LowerBound; rol2.count <= Upper Bound end – class Class1

Traducción de asociacionesTraducción de asociacionesP&MP&M

class Class2 ... feature {NONE} -- data members for association Association_Name rol1: UnbondedCollectionby Reference [Class1]; mult_rol1: MULTIPLICITY; -- operations for association Association_Name ... add_rol1( e: Class1) is require is-related_rol1 (e) and and not get_frozen_rol1 and multiplicity_rol1get_mult_rol1.get_upper_bound do rol1. put (e) end; is_related_rol1 (e: Class2): BOOLEAN is do Result:=rol1. has (e) end;

Traducción de asociacionesTraducción de asociacionesP&MP&M

class Class2 ... invariant mult_ rol1.get_lower_bound = LowerBound; mult_ rol1.get_upper_bound = Upper Bound; rol1.count >= LowerBound; rol1.count <= Upper Bound end – class Class2

Traducción de NEREUS Traducción de NEREUS

a Lenguajes Formalesa Lenguajes Formales

Desde NEREUS a lenguajes Desde NEREUS a lenguajes formalesformales

Se seleccionó como lenguaje formal a CASL (Common

Algebraic Specification Language) Lenguaje de especificación algebraica de propósito

general Tiene una definición semántica sólida Es soportado por herramientas Facilita interoperabilidad con otros prototipos y

herramientas “formales”

Traducción de NEREUS a CASL

ClasesClases RelacionesRelaciones

HerenciaHerencia ClienteCliente

FuncionesFunciones Higher-order Higher-order VisibilidadVisibilidad

AsociacionesAsociaciones

PackagesPackages

Traducción de asociacionesTraducción de asociaciones NEREUS/ CASL NEREUS/ CASL

Paso 1: Reagrupar las operaciones de las clases A y B distinguiendo operaciones locales a A y a B y locales a A, B y Assoc.

A BAssoc

LOCAL OPERACIONES

/ATRIBUTOS

Person name

Meeting tittle, start, end, duration

Person, Meeting, Participates cancel,isConfirmed, numConfirmedMeetings,

checkDate, numMeetings

Traducción de asociacionesTraducción de asociaciones NEREUS/ CASL NEREUS/ CASL

spec PERSON given STRING, NAT =then generated type Person ::= create-Person (String)opsname: Person -> StringsetName :Person x String -> Nameend

spec MEETING given STRING, DATE =then generated type Meeting ::= create-Meeting ( String;

Date; Date)Opstittle: Meeting -> Stringset-title: Meeting x String -> Meetingstart : Meeting -> Dateset-start: Meeting x Date -> Meeting isEnd: Meeting -> Dateset-end: Meeting x Date -> Meeting end

Paso 2: Construir las especificaciones C y D a partir de A y B donde C y D incluyen operaciones locales a A y B respectivamente

Traducción de asociacionesTraducción de asociacionesNEREUS/CASLNEREUS/CASL

spec SET-PERSON given NAT= PERSON and BAG[PERSON] and …thengenerated type Set[Person] :: = create | including (Set[Person];

Person)opsunion : Set[Person] x Set[Person] -> Set [Person]intersection : Set[Person] x Set[Person] -> Set [Person]count: Set[Person] x Person -> Nat…

spec SET-MEETING given NAT = MEETING and BAG[MEETING] and …

then generated type Set [Meeting] :: = create | including (Set[Meeting];

Meeting)…

Paso 3: Construir las especificaciones Collection[C] y

Collection [D] a partir de esquemas reusables

Traducción de asociacionesTraducción de asociacionesNEREUS/CASLNEREUS/CASL

spec PARTICIPATES = SET-PERSON and SET-MEETING andBINARY-ASSOCIATION [PERSON][MEETING] with BinaryAssociation|->

ParticipatespredisRightLinked: Participates x Person isLeftLinked: Participates x MeetingisRelated: Participates x Person x MeetingopsaddLink: Participates x Person x Meeting -> ParticipatesgetParticipants: Participates x Meeting -> Set [Person] getMeetings: Participates x Person -> Set[Meeting]remove: Participates x Person x Meeting -> Participates a : Participates; p,p1: Person; m,m1: Meetingdef addLink (a,p,m) not isRelated (a,p,m)def getParticipants (a, m) isLeftLinked (a,m)def getMeetings (a, m) isRightLinked ( a, m)def remove (a,p,m) isRelated (a, p, m)end

Paso 4:Paso 4: Construir una especificación Assoc Construir una especificación Assoc (con Collection[C] y (con Collection[C] y Collection[D]) instanciando esquemas reusables en el Collection[D]) instanciando esquemas reusables en el componente Associationcomponente Association

Traducción de asociaciones Traducción de asociaciones NEREUS/CASLNEREUS/CASL

spec PERSON&MEETING = PARTICIPATESthen opsnumMeeting : Participates x Person -> NatnumConfirmedMeeting : Participates x Person -> NatisConfirmed : Participates x Meeting -> BooleannumConfirmedParticipants: Participates x Meeting ->

NatcheckDate: Participates x Meeting -> Participatesselect : Participates x Set[Meeting] -> Set[Meeting]collect: Participates x Set[Person] -> Bag[Meeting]pred forall: Participates x Set[Meeting] x Meeting

Paso 5:Paso 5: Construir la especificación AssocA+B Construir la especificación AssocA+B extendiendo extendiendo AssocAssoc con con CC, , DD y las operaciones locales a y las operaciones locales a CC, , DD y y Assoc.Assoc.

Traducción de asociacionesTraducción de asociacionesNEREUS/CASLNEREUS/CASL

s : Set[Meeting]; m:Meeting; pa:Participates; p:Person; m:Meeting;sp:Set[Person]; bm: Bag[Meeting]forall (pa, including(s,m),m1) = isConsistent(m,m1) and forall(pa, s, m1)select(pa, create-Meeting) = create-Meetingselect (pa, including (s,m)) = including(select(s,pa),m) when isConfirmed (pa, m)

else select (s,pa)collect (pa, create-Person,s) = asBag (create-Person)collect (pa, including (sp, p) ) = asBag (including (collect (pa,sp), p))numMeeting( pa, p) = size (getMeetings(pa, p))isConfirmed (pa, m)=checkDate (pa,m) and

NumConfirmedParticipants(pa,m) >2numConfirmedMeeting (pa, p) = size (select (getMeetings (pa,p))checkDate (pa, m) = forall (pa, collect (getParticipants(pa,m), m)isConsistent (pa, m, m1) = not (isConfirmed (pa,m1)) or (end(m) <

start (m1) or end (m1) < start(m))numParticipantsConfirmed (pa, m) = size( getParticipants (pa, m))end

Paso 5:Paso 5:

Traducción de asociacionesTraducción de asociacionesNEREUS/CASLNEREUS/CASL

Person&Meeting

Participates

SetPerson SetMeeting

Person Meeting

name

tittlestartendduration

getMeetingsgetParticipates

forAllselectcollect

numMeetingsnumConfirmedMeetingsisConfirmedcheckDatecancel

Especificando transformaciones Especificando transformaciones

en NEREUSen NEREUS

Un “Megamodelo”de Un “Megamodelo”de componentes para MDAcomponentes para MDA

PIMMetamodel

Postcondition

Parameters

Precondition

Postcondition

Refinement PIM-PSM

**source1

PSM Metamodel

1* target

ISM Metamodel

Refinement PSM-ISM

** source

1

* target

1*

Postcondition

Parameters

Precondition

Postcondition

“ “Megacomponentes”: Megacomponentes”: El patrón Observer El patrón Observer

Observer PatternPIM Metamodel

UML/OCL

RefinementPIM to PSM EIFFEL

RefinementPIM to PSM J2EE

Observer PatternPSM MetamodelJ2EE

Observer PatternISM MetamodelEIFFEL

Observer PatternISM MetamodelJAVA

RefinementPSM Eiffel to ISM Eiffel

Refinement PSM J2EE to ISM JAVA

Observer Pattern PSM Metamodel EIFFEL

Observer PatternPSM Metamodel.NET

Observer PatternISM MetamodelC#

RefinementPSM .NET to ISM C#

RefinementPIM to PSM .NET

“megacomponente”: instancia del “megamodelo”

Metamodel 1

Postcondition

Precondition

Postcondition

Transformation

Metamodel 2

CLASS name [metamodelName1:source; metamodelName2: target]GENERATED-BY create, addLinkEFFECTIVETYPE nameFUNCTIONScreate: -> nameaddLink: name (t) x metamodelName1 (m1) x metamodelName2 (m2) -> namepre: TranslateNEREUS (Transformation.precondition)remove: name (t) x metamodelName1 (m1) x metamodelName2 (m2) -> namepre: isRelated (t, m1, m2)isRelated: name x metamodelName1 x metamodelName2 -> BooleanisEmpty: name -> Booleanget_Pim: name (t)-> metamodelName1pre: not isEmpty (t)get_Psm: name (t)-> metamodelName2pre: not isEmpty (t)AXIOMS t:name; m1,m3:metamdoelName1; m2,m4:metamodelName2isRelated(t, m1, m2) implies Translate NEREUS(Transformation.postcondition)…END-CLASS

Un esquema de transformaciónUn esquema de transformaciónpara refinamientos para refinamientos

CLASS PimUmlToPsmEiffel [ObserverMetamodel : source; ObserverMetamodelEiffel : target]

... FUNCTIONScreate: -> PimUmlToPsmEiffel addLink: PimUmlToPsmEiffel (t) x ObserverMetamodel (m1) x ObserverMetamodelEiffel (m2)

-> PimUmlToPsmEiffel pre: isEmpty(get_importedElements(ElementImport-PackageableElement, m1) isRelated: PimUmlToPsmEiffel x ObserverMetamodel x ObserverMetamodelEiffel -> Boolean... AXIOMS t : PimUmlToPsmEiffel, m1: ObserverMetamodel , m2: ObserverMetamodelEiffel

isRelated(t,m1,m2) implies size( select s(get_ownedElement(Element-Element,m1), [oclIsTypeOf(Class,s) or oclIsTypeOf(Interface, s)] ) =size(select e (get_ownedElement(Element-Element,m2), [oclIsTypeOf(EiffelClass,e)]) andforAll sourceClass(select source (get_ownedElement(Element-Element,m1), [exists targetClass (select tc (get_ownedElement(Element-Element), m2), [oclIsTypeOf(EiffelClass, tc)]), [name(sourceClass) = name(targetClass) and… ... END-CLASS

Formalización de refinamientosFormalización de refinamientos

ResumenResumen

Metamodelos MOF Leng.Formales

Leng.Programación

LenguajeNEREUS

Transformaciones automáticas

ResumenResumen NEREUS provee las ventajas de un NEREUS provee las ventajas de un

lenguaje intermediolenguaje intermedio Es textual, alineado con MOFEs textual, alineado con MOF

MetamodelosMetamodelos GramáticasGramáticas

Interoperabilidad a nivel de lenguajesInteroperabilidad a nivel de lenguajes Semántica “más precisa” de UML 2.0 y Semántica “más precisa” de UML 2.0 y

OCL 2.0OCL 2.0 Traducciones “constructivas” que Traducciones “constructivas” que

permiten automatizaciónpermiten automatización