180 likes | 193 Views
Modeling Aspects by Category Theory. Serge P. Kovalyov Novosibirsk, Russia. FOAL 2010. Aspect-oriented software development. Mission: explicit separation and composition of concerns Motivation Concerns are tangled Concerns crosscut modular architecture bounds
E N D
Modeling Aspects by Category Theory Serge P. Kovalyov Novosibirsk, Russia FOAL 2010
Aspect-oriented software development • Mission: explicit separation and composition of concerns • Motivation • Concerns are tangled • Concerns crosscut modular architecture bounds • Traceability is compromised (ability to determine what each fragment of the system is included into it for) • Proposed solution • Equip program models with traces of refinements that produce them from concerns (i.e. “label” programs by concerns) • Explicitly identify, compose (weave), and separate concerns • Application: enhance modular design technologies with aspect handling capabilities • FOAL 2010
Category-theoretic formalization • Explicit definition of intuitive notions • Objects (things) • Morphisms (connections) • Functors (translations) • Describing objects via relations with similar objects • Avoiding appeal to “interiors” of objects • Constructing object by systemic criteria • Universality (existence and uniqueness of connection with similar objects) • Naturality (independence of the result on the way it is reached) • Formal specification and verification of systemic properties • Complexity • Modularity • Traceability • FOAL 2010
Category of descriptions • Category c-DESC • Objects are formal models of programs (descriptions) • Morphisms are actions of integrating components into systems • Composition is multistep integration • Identity morphisms are “doing nothing” • Example: category of UML classes and inheritance relations • Scenario modeling • Category Pos • Objects are partially ordered sets (posets) of events ordered by causal dependence • Morphisms are poset homomorpisms (preserving events and ordering) • FOAL 2010
Diagrams • c-DESC-diagram • Functor : Xc‑DESC • Graph of X labeled by c‑DESC-objects and c‑DESC-morphisms • Cocone • Natural transformation of a diagram (base) to a singleton (vertex) • Colimit of a diagram • Universal cocone with base • Minimal “container” that encapsulates objects of respecting their interconnections • FOAL 2010
Configurations • Well-formed configuration • Is a c-DESC-diagram (of components and their interconnections) • Has a colimit (system built from interconnected components) • Satisfies structural constraints • Configurations of scenarios • Well-formed configurations are disjoint unions of cocones • Examples well-formed: parallelism ill-formed: concurrency • FOAL 2010
Interfaces • Category SIG of interfaces and their integration actions • Functor sig : c-DESCSIG • Default realization of any interface • Functor sig* : SIGc-DESC • sig ◦ sig* = 1SIG • Bijective map Mor(sig*(I), A) to Mor(I, sig(A)) by functor sig (i.e. sig* is left adjoint to sig with identity as the unit) • Example: signature of a program module • Scenario interface • Set of events • Forgetful functor |–| : PosSet |–| • FOAL 2010
Refinements • Categoryr-DESC • Objects are models • Morphisms are refinements (individual component development steps) • Examples • Elaborating requirements • Implementing specification by means of a programming language • Scenario refinement • Replacing atomic events with subscenarios fully inheriting the order • Dual to a surjective homomorphism • FOAL 2010
Traceable refinements r s : sig(t) ◦ s = 1 XS sig(X) sig(S) t = rop sig(t) sig • Every refinement of scenarios is traceable • Tracing a refinement r : XS • Labeling S by concerns that constitute X • Trace is a c-DESC-morphism t : SX dual to a refinement • sig(t) has right inverse (to preserve traceability at subsequent integrating S into a larger system) • FOAL 2010
Enhancing descriptions with aspects • Aspect-oriented description is a pair A, l : sig(A) L • AOb c‑DESC is a “modular” part • LOb SIG is an aspect structure • llabelssig(A) by aspects (sig(l)is a trace) • Morphism of AO-description A, l to A', l' is a pairp, q A,l:sig(A) L psig(p)q A', l':sig(B) L' • Aspect-oriented scenarios • Object are pomsets (labeled posets) • Morphisms are homomorphisms that preserve labeling • FOAL 2010
Aspect-oriented design • AO-configurations are modular configurations that admit any labeling of components by aspects (i.e. have suitable colimit) • Interfaces of AO-descriptions • mod : A, l |A(modular design interfaces) • asp : A, l |l(aspect design interfaces) • int : A, l |sig(A) (original interfaces) • AO-refinements are duals to such AO-morphisms that are produced from traces • Aspect-oriented scenario modeling • Configurations are disjoint unions of AO-cocones • Functor mod forgets labeling • Functor mod* labels each event by a unique label (event itself) • Refinement replaces events with subscenarios fully inheriting the order and detailing the labeling • FOAL 2010
Aspects • Aspects are “elementary” building blocks of AO-descriptions • An integration of an aspect into a system is an invertible embedding at the level of aspect structures • A is an aspect iff for every object A' and morphism p, q : AA' q has left inverse (often a trace) • Aspects in scenario modeling • Aspect is a scenario with all events labeled by the same label • Aspect is precisely a pair A, ! : |A|1 • FOAL 2010
Weaving • Specifying how to weavean adviceWwith a base programB • Connector: C • Pointcut descriptor: j : CB • Entry points descriptor:e : CW • Performing weaving • Pushout (colimit): 1C, e :C CW j BX • Weaving labeled scenarios • Weaving exists if a connector “tolerates” concurrency (i.e. it doesn’t impose specific order of executing different aspects of the advice bound to the same join point) • Weaving with an aspect preserves labeling of a base • FOAL 2010
Explication of aspect structure • Explication of aspect structure of an AO-description A, l • Obtaining “actual” refinement from concerns • r‑DESC-morphism s : XA where sop is a trace and sig(sop) = l • An explication of A, l is universal if every AO-morphism p, q : A, lA', l' has an explication (provided that A', l' has) p :A A' sop rop p' :XX' • Explicating labeled scenarios • Every explication is universal • Every aspect is explicable • “Many” scenarios are inexplicable e.g. interleaving • FOAL 2010
Separation of concerns • Subaspect of an AO-description S • AO-morphismm : AS where A is an explicable aspect • Explication m' of m is right inverse to a trace • Explication diagram of m is a pullback (i.e. mod(m) is a “preimage” of m' along an explication trace of S) • An aspect has no proper subaspects • If S is an aspect, then m is an isomorphism • Each explicable labeled scenario can be partitioned to subaspects • Each scenario can be labeled by linearly ordered subaspects • Maximal partition: assign a unique label to each event (i.e. apply mod*) • Minimal partition: factorize by linear equicomparability relation • FOAL 2010
Industrial application • Distributed measurement system (DMS) development • Main measurement cycle is linear order of separable aspects • Measurement automation infrastructure aspects are woven to it undermining separation of concerns • DMS scenario weaving schema measure store validate compute display • FOAL 2010
Summary • Understanding systemic nature of AOSD concepts • Providing formal paradigm-neutral description of • Aspects • Weaving • Explication of aspect structure • Separation of concerns • Verifying structural properties of aspect-oriented operations • Applying in concurrency theory: labels are aspects • Applying in industry: large-scale DMS development • FOAL 2010
Thank you for your attention • FOAL 2010