Date post: | 30-Dec-2015 |
Category: |
Documents |
Upload: | dorcas-warner |
View: | 216 times |
Download: | 2 times |
Aspect Oriented Programming
Razieh Asadi
University of Science & Technology
Mazandran Babol
Aspect Component Based Software
Engineering (ACBSE)
programming languages and software design processes
Design processes : break a system down into smaller and smaller units
Programming languages : define abstractions of system sub-units, compose those abstractions to produce the overall system
Abstraction and composition mechanisms is common key
object-oriented languages, procedural languages and functional languages
Requirement
Functional :
system must able to do it .
e.g. registering in education system.
Nonfunctional :
Issues in connection with the system and how to do tasks well .e.g. Performance, Quality of Service.
What is a Concern ?
One or more requirement related to
stakeholders and development, able to
implement with a code structure
Core Concerns :–Necessary for correct ?
–Is part of program Logic
–Encapsulate in module
What is a Concern ? (cont 1)
Crosscutting Concerns:
–Is not part of program Logic . e.g. Logging
–Cannot be cleanly encapsulated in a module and affect on many module
–Lack of clear separation in design and implementation
–Tangling and Scattering
What are the Crosscutting Concerns ?
Tangling–Code separate in multiple module
Scattering
–Code mixed with code of other concerns
Crosscutting Concerns
Infrastructure Concern–Nonfunctional requirement. e.g. security, logging
Peers Concern–Functional requirement–Overlap in implementation
Extension Concern –Functional requirement–New concern over basic concerns
What Is an Aspect ?
Aspects are an program unit of modularity.
Avoid of separation cross-cutting code
Implement Crosscutting Concerns
Without Aspect
With Aspect
What Is an Aspect ? (cont.)
Aspect Consists of two sections :
Advice code
Including piece of code that must be executed (After, Before, Around)
Pointcut
Points that advice code must be executed
in
Aspect Oriented programming
Crosscutting concerns are implemented in aspects instead of fusing them into core modules.
By reducing code tangling it makes it easier to understand what the core functionality of a module is.
Not replacement for OOP
Aspect Weaver
Integration takes the aspects and the core modules and composes the final system
Can be implemented in various waysCompile-Time
By the language compiler
Loading-Time first compile source with original compiler, then weave aspects into class files
Run-Time By a classloader
Aspect Weaver
Programming environment
Use a Object Oriented language–E.g. Java, C++
AspectJWeaving in loading and compiling time
Java Aspect Component (JAC)Weaving in run time
JBoss AOPWeaving in run time And open source
Example
public class Example {
public static void deliverMessage(String essage){ println ("The message is: " + message);}
public static void main(String [] args) { deliverMessage("I'm here"); … deliverMessage("AspectJ rocks");}
}
Example
public aspect ExampleAspect {
pointcut helloPC() : call(void Example.deliverMessage(..));
before() : helloPC(){ System.out.print("Hello! ");}
after() : helloPC() { System.out.println("The message has been delivered.");}
}
Current CBSE problems
Lack of reusability and adaptability in
CBSE
Code-tangling is inherent to CBSE program (crosscutting concern)
Uses statement (like CCM statement)
during component specification may be considered harmful
Current CBSE problems (cont.)
CBS adaptability and reusability
Updating Non-functional properties
in CCM each component can be configured in Package Phase.
Updating functional properties
Container can not be used, business rules change for system , specify in Design Phase
Current CBSE problems (cont.)
Aspect Component Based Software
Engineering (ACBSE) solved this problem
New requirements involve change in all
of the component life cycle
AOP create changes in each
component based system development
phase
Dependency in Specification Phase
Belong to the component
Must be maintained by all implementations
Use of component is quite limited
New dependencies becomes difficult task
Solution :
Specify dependencies avoiding crosscutting
at the Implementation Phase
Dependency in Implementation Phase
Dependency
1. Intrinsic
2. Non-intrinsic
Solution :
Each component only implements the
basic business functionality (intrinsic)
Dependency in Package Phase
1. Define during system design phase (UML)
2. Dependencies in UML translated to XML Descriptor Specification
3. XML descriptor describes the on-intrinsic for each component
4. Recompile the component code, add restriction and dependencies that specified in XML descriptor
5. These dependencies are expressed as aspect
Dependency in Package Phase
XML descriptors use to describe the component properties
Allows us to apply the non-intrinsic dependencies
Dependencies with other component are not expressed in the implementation
Dependency in Assembly and Deployment Phase
Define non-intrinsic and intrinsic dependencies
Dependencies in UML translated to XML Assembly Descriptor
Permit us to connect the component implementation
ACBSE advantages
ReusabilityComponent is not recoded, implementation adapted to new business rules by changing non-intrinsic dependencies
AdaptabilityModifying the component descriptor by altering the final component functionality
ScalabilityNew components with their intrinsic and non-intrinsic dependencies can be used to compose new system
References
[1] Pedro J. Clemente and Juan Hernández, Aspect Component Based Software Engineering, University of Extremadura. Spain
[2] Gregor Kiczales, et al., Aspect-Oriented Programming,
proceedings of the European Conference on Object-Oriented
Programming (ECOOP), Finland. Springer-Verlag LNCS
1241. June 1997.
Aspect Oriented Programming
The end
07.01.2010
Aspect Component Based Software
Engineering (ACBSE)