Presentation is loading. Please wait.

Presentation is loading. Please wait.

AspectAda Aspect-Oriented Programming for Ada95

Similar presentations


Presentation on theme: "AspectAda Aspect-Oriented Programming for Ada95"— Presentation transcript:

1 AspectAda Aspect-Oriented Programming for Ada95
Computer Science & Software Engineering AspectAda Aspect-Oriented Programming for Ada95 WORLD CLASS – through people, technology and dedication KONGSBERG April 23, 2019

2 Agenda Separation of Concerns + Crosscutting
Aspect-Oriented Programming (AOP) Model Logging Example AspectAda Prototype Architecture Effect on SW Quality KONGSBERG April 23, 2019

3 Separation of Concerns (SoC)
“Separation of Concerns (SoC)” (Parnas, Dijkstra): realization of problem domain concepts into separate units of software. Benefits of SoC Better analysis and understanding of systems Easy adaptability, maintainability and high degree of reusability. Low Coupling/High Cohesion SoC Fundamental to SW Development Ada95 SoC Packages, Subprograms, Tagged Types, Protected Types, Tasks KONGSBERG April 23, 2019

4 Crosscutting Concerns
Certain properties cannot be localized in single modular units, but their implementation cuts across the decomposition hierarchy of the system. These properties are called crosscutting concerns, or aspects. Concern (Requirement) Functional Non-functional Design Crosscutting Concern A concern that is implemented in more than one location security, logging, synchronization, fault tolerance, design by contract KONGSBERG April 23, 2019

5 Initial Picture of Crosscutting
[Constantinides] KONGSBERG April 23, 2019

6 CORBA Servant Implementation
procedure Do_Some(Self: in out Object; Data : in Data_t) is begin  Tracer.Enter(Self.TraceId, “Do_Some”);  Mutex.Lock(Self.Lock); .... -- Do business-logic --(Also invoking methods across CORBA) Fault_Tolerance.Log_State(Make_Stream(Data)); Mutex.Unlock(Self.Lock); Tracer.Exit(Self.TraceId, “Do_Some”); exception when event : others =>  Mutex.Unlock(Self.Lock);  Error_Logger.Log_Error(event, “Unknown Exception in Do_Some”); end Do_Some; KONGSBERG April 23, 2019

7 Crosscutting identification
procedure Do_Some(Self: in out Object; Data : in Data_t) is begin  Tracer.Enter(Self.TraceId, “Do_Some”);  Mutex.Lock(Self.Lock); .... -- Do business-logic --(Also invoking methods across CORBA) Fault_Tolerance.Log_State(Make_Stream(Data)); Mutex.Unlock(Self.Lock); Tracer.Exit(Self.TraceId, “Do_Some”); exception when event : others =>  Mutex.Unlock(Self.Lock);  Error_Logger.Log_Error(event, “Unknown Exception in Do_Some”); end Do_Some; KONGSBERG April 23, 2019

8 Symptoms of Crosscutting
Crosscutting imposes two symptoms on software development: Code scattering: implementation of some concerns not well modularized but cuts across the decomposition hierarchy of the system. Code tangling: a module may contain implementation elements (code) for various concerns. Problems Low cohesion Strong coupling Low reusability, adaptability Difficult comprehensibility KONGSBERG April 23, 2019

9 AOP Version Aspects Composition rules Tracer Mutex FT State
procedure Do_Some(Self: in out Object; Data : in Data_t) is begin -- Do business-logic --(Also invoking methods across CORBA) end Do_Some; Aspects Tracer Mutex FT State Exception handling Composition rules Rules for inserting aspect behavior to components KONGSBERG April 23, 2019

10 AOP Programming Model KONGSBERG April 23, 2019

11 Aspect Oriented Programming
AOP Complementary to OOP as OOP was to procedural programming Also applicable to procedural programming Aspect Languages extends traditional programming languages Abstractions for representing crosscutting concerns (Aspects) Composition of Aspects and traditional modules (Weaving) Improves modularity, adaptability, traceability AspectJ – Dominant AOP language extension for Java AspectAda – Our Proposal to extend Ada95 Influenced by AspectJ KONGSBERG April 23, 2019

12 Joinpoint Well defined instant in the execution of a program
Subprogram execution Finalization, Initialization, Adjust (Controlled Types) Variable access (Object declarations) Package body statement block Named block statements Named loop statements Rendezvous/Entry points procedure Do_Some(Self: in out M_Object; Data : in Data_t) is ... begin end Do_Some; KONGSBERG April 23, 2019

13 Pointcuts Set of joinpoints (object declaration)
Pointcut expression (AspectJ Influenced) Primitive pointcuts Call Execution Get/Set of variables Wildcard matching (*, ..) Composition using and, or, xor, not When a pointcut is matched, an advice can be executed My_PC : Pointcut := execution Some_Pk.Do_* (in out M_Object; ..) or execution Some_Pk.Set_* (in out M_Object; ..); KONGSBERG April 23, 2019

14 Advice Code module (as a subprogram) that attaches to a pointcut
Injects behavior at all joinpoints selected by that pointcut Three types: Before (code injected before the joinpoint) After (code injected after the joinpoint) Around (code injected around (in place of) code from joinpoint advice Around(Mutex_A : in out Mutex_Aspect) is begin Mutex_A.Mutex.Lock; Proceed; Mutex_A.Mutex.Unlock; when others => raise; end Around; KONGSBERG April 23, 2019

15 Aspect A modular unit of crosscutting behavior
Advice type (tagged) Simple (Performance) Detailed (Contextual information) Advice(s) bound to pointcut(s) (Advice clause) Like a package can have subprograms, types ... Parameterized to bind to one or more pointcut(s) generic Mutex_P : Pointcut; aspect Mutex_Aspects is type Mutex_Aspect is new Simple_Aspect with record Mutex : Mutex_t; end Mutex_Aspect; advice Around..... for Around’Advice use Mutex_P; end Mutex_Aspects; Generic Aspect Composition rules Ada95 Modules KONGSBERG April 23, 2019

16 Logging Example KONGSBERG April 23, 2019

17 AOP Tracing Example: Aspect Spec
with AspectAda; generic Tracer_P : Pointcut; aspect Tracer is type Tracer_Aspect is new Aspect_Ada.Detailed_Aspect with null record; advice Before(Tracer : in Tracer_Aspect); for Before’Pointcut use Tracer_P; advice After(Tracer : in Tracer_Aspect); for After’Pointcut use Tracer_P; end Tracer; KONGSBERG April 23, 2019

18 AOP Tracing Example: Aspect Body
with Ada.Text_IO; use Ada.Text_IO; with Aspect_Ada; use Aspect_Ada; aspect body Tracer is advice Before(Tracer : in Tracer_Aspect) is begin Put_Line(“==> “ & Image(Get_Join_Point(Tracer).all)); end Before; advice After(Tracer : in Tracer_Aspect) is begin Put_Line(“<==” & Image(Get_Join_Point(Tracer).all)); end After; end Tracer; KONGSBERG April 23, 2019

19 AOP Tracing Example: Composition Rules
with Tracer; use Tracer; weaver CMS_Proto is Gun_Control_All_PC : Pointcut := execution Gun*.*(..); aspect Gun_Control_Logger is new Tracer_Aspect(Tracer_P => Gun_All_PC); end CMS_Proto; KONGSBERG April 23, 2019

20 AspectAda Prototype Architecture
KONGSBERG April 23, 2019

21 AspectAda Architecture: Conceptual View
[Hofmeister Notation] KONGSBERG April 23, 2019

22 Weaver Prototype: Modular View
ASIS Based (Ada95) AdaGOOP (Aspects, Pointcuts) Ada.Containers Easy to adapt to Ada2005 Merging Selection ASIS Aspect Parser Pointcut JoinPointModel Controller KONGSBERG April 23, 2019

23 Effects on SW Quality KONGSBERG April 23, 2019

24 Effects on SW Quality Cohesion Coupling Adaptability
One concern in Ada95 module Crosscutting concerns modularized in aspects Coupling Minimal coupling modeled using pointcut expressions Reversed dependency direction Adaptability Code comprehensibility Tradeoff Traceability KONGSBERG April 23, 2019

25 Future Work Extended joinpoint model
Call, Set/Get Named blocks, named loops Export of context at Joinpoints (objects, arguments) Extend GPS Plugin (GNAT Programming System) Joinpoint model and Ada generics Increased Aspect reusability Design by contract support Open for suggestions KONGSBERG April 23, 2019

26 Conclusion Crosscutting concerns
Joinpoint model (joinpoints, pointcuts, advices, aspects) Tracing using AspectAda AspectAda Prototype Architecture Effects on SW Quality Future Work KONGSBERG April 23, 2019

27 WORLD CLASS – through people, technology and dedication
End WORLD CLASS – through people, technology and dedication KONGSBERG April 23, 2019


Download ppt "AspectAda Aspect-Oriented Programming for Ada95"

Similar presentations


Ads by Google