Performance analysis of synchronisation problem

Post on 15-Apr-2017

146 views 2 download

transcript

PERFORMANCE ANALYSIS OF SYNCHRONISATION PROBLEM USING ASPECT ORIENTED PROGRAMMING

Submitted by:-Harshit monish9911103466F-4

OVERVIEW Cross Cutting Concerns

Logging Producer Consumer problem(synchronization)

The cost of tangled code Aspect Oriented Programming Development stage Terminology Aop benefits and oop shortcomings Producer Consumer problem

CROSS CUTTING CONCERNS:- What is a crosscutting concern?

Behavior that cuts across the typical divisions of responsibility, such as logging or debugging

A problem which a program tries to solve. Aspects of a program that do not relate to the

core concerns directly, but which proper program execution nevertheless requires

Function Requirements

Non-FunctionalRequirements

Production Code

=+

CROSS CUTTING CONCERNS:- Examples Synchronisation Logging Authorisation Exception handling

LOGGING WITHOUT AOP

LOGGING WITH AOP

PRODUCER CONSUMER PROBLEM

TWO PROBLEMS AOP TRIES TO SOLVE

TWO PROBLEMS AOP TRIES TO SOLVE

THE COST OF TANGLED CODE redundant code

same fragment of code in many places difficult to reason about

non-explicit structure the big picture of the tangling isn’t clear

difficult to change have to find all the code involved and be sure to change it consistently Poor traceability Lower productivity Less code reuse Harder refactoring

ASPECT ORIENTED PROGRAMMING AOP is a programming paradigm which aims

to increase modularity by allowing the separation of cross-cutting concerns

In AOP crosscutting concerns are implemented in aspects instead of fusing them into core modules.

Aspects can be reused. By reducing code tangling it makes it easier

to understand what the core functionality of a module is.

An “aspect weaver” takes the aspects and the core modules and composes the final system

Coding is HARD

AOP makes it EASY

AOP DEVELOPMENT STAGESIntegrating all concerns

Identify concerns

What’s in it for YOU?

BENEFITS Write less code Read less code More concise and easy to understand More maintainable Fewer code = Less boilerplate code More interesting work Increased attention More PRODUCTIVITY!

FEWER DEFECTS!

TERMINOLOGYCross-cutting – Identify areas of code

where common functionality exists Advice – The code to be injected Joinpoint – Where one or more

aspects can be appliedPointcut – A collection of joinpointsAspect – General term for where

advice and point-cuts are combined

TERMINOLOGYWeaving – Integrating applications

and aspects (e.g. AspectJ is an “aspect weaver”)

Compile-time – Can produce integrated source-code, but typically only produces woven byte-code.

Run-time – Aspects are applied “on the fly” (typically when classes are loaded)

OOP SHORTCOMINGS OOP allows to decompose a system into units of

function or behavior Certain software properties cannot be isolated in

single functional unit, instead they crosscut multiple components

Such crosscutting concerns result in tangled code that is hard to develop and maintain

AOP BENEFITS Separation of components and aspects

Better understanding of software because of high level of abstraction

Easier development and maintenance because tangling of code is prevented

Increased potential for reuse for both components as well as aspects

AOP breaks encapsulation in a controlled manner.

Encapsulation is broken between classes and aspects.

Aspects marked as privileged have access to the private members of a class.

Encapsulation is preserved between classes.

An aspect encapsulates a crosscutting concern.

WHAT ABOUT ENCAPSULATION?

PROBLEM DESCRIPTION Question: ''How to enforce synchronization

policies with AOP?''

Suppose multiple objects are concurrently working on some shared data and exclusive access is needed for modification

All objects that are working on the data must be synchronized, for example by locking the shared data temporarily

PROBLEM DESCRIPTION Question: ''How to enforce synchronization

policies with AOP?''

Suppose multiple objects are concurrently working on some shared data and exclusive access is needed for modification

All objects that are working on the data must be synchronized, for example by locking the shared data temporarily

OBSERVATION Without AOP

Every component that works on the shared data must take care of the locking itself, leading to tangled and complex code

With AOP The locking aspect is separated from the components

by means of an aspect module, resulting in usual benefits of modularization

THE PRODUCER CONSUMER ASPECT