Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 17

Aspect Oriented Programming

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

S.D.M COLLEGE OF ENGINEERING AND TECHNOLOGY

A seminar report on

Aspect Oriente !ro"rammin"

S#$mitte $%

Jeevan Dongre 2SD04CS111 8 semester


DE!ARTMENT OF COM!UTER SCIENCE ENGINEERING &''()*'
th

DEPT OF CSE,SDMCET, DHARWAD

Aspect Oriented Programming

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

S.D.M COLLEGE OF ENGINEERING AND TECHNOLOGY

DE!ARTMENT OF COM!UTER SCIENCE ENGINEERING

CERTIFICATE
Certified that the seminar work entitled Aspect Oriented Programming is a bonafide work presented by Jeevan Dongre bearing U ! !O " D#$C %%% in a partial f&lfillment for the award of degree of 'achelor of (ngineering in Comp&ter cience (ngineering of the )isvesvaraya *echnological University+ 'elga&m d&ring the year "##,-%#. *he seminar report

has been approved as it satisfies the academic re/&irements with respect to seminar work presented for the 'achelor of (ngineering Degree.

Sta++ in c,ar"e

H.O.D CSE

Name-.ee/an Don"re. USN-&SD'0CS***


2

DEPT OF CSE,SDMCET, DHARWAD

Aspect Oriented Programming

INDE1 N O 1 2 ! 4 ' ( ) 8 * 10 11 12 Introduction Histor Introducing concerns" cross#cutting concerns" Aspects $ AO Imp%ications o& cross#cutting concerns AOP Deve%opment Stages Anatom o& AOP %anguages AOP %anguage Imp%ementation Current% used AOP too%s +,amp%e Code o& AspectJ AOP -ene&its .Conc%usion /e&erences !a" e 0 0 0 2 3 4 ( ( *' *' ** **

DEPT OF CSE,SDMCET, DHARWAD

Aspect Oriented Programming

*. Intro #ction
As g%o-a% digita%i0ation and the si0e o& app%ications e,pand at an e,ponentia% rate" so&t1are engineering comp%e,ities are a%so gro1ing. One &eature o& this comp%e,it is the repetition o& &unctiona%it such as securit " memor management" resource sharing" and error and &ai%ure hand%ing throughout an app%ication. 2o address this issue" so&t1are researchers are deve%oping methodo%ogies -ased on a ne1 programming e%ement3 the aspect. Aspect Oriented Programming is a mindset3 a ne1 programming methodo%og invo%ving the aspects.

&. Histor%
AOP as such has a num-er o& antecedents3 the 4isitor Design Pattern" C5OS 6OP" and others . AspectJ 8perhaps the most popu%ar genera%#purpose AOP pac9age: 1as created - ;regor <ic0a%es and co%%eagues at =ero, PA/C and made avai%a-%e in 2001. I>6?s research team emphasi0ed the continuit o& the practice o& modu%ari0ing concerns 1ith past programming practice" and o&&ered the more po1er&u% 8-ut %ess usa-%e: H per@J and Concern 6anipu%ation +nvironment" 1hich have not seen 1ide usage.
7

5. Intro #cin" concerns6 cross)c#ttin" concerns6 Aspects 7 AO!


Concerns
2he part o& the so&t1are that is re%evant to a particu%ar concept" goa% or purpose.

Ae can vie1 a comp%e, so&t1are s stem as a com-ined imp%ementation o& mu%tip%e concerns. A t pica% s stem ma consist o& severa% 9inds o& concerns" inc%uding -usiness %ogic" per&ormance" data persistence" %ogging and de-ugging" authentication" securit " mu%tithread sa&et " error chec9ing" and so on. 2here are a%so deve%opment#process concerns" such as comprehensi-i%it " maintaina-i%it " tracea-i%it " and evo%ution ease. .

DEPT OF CSE,SDMCET, DHARWAD

Aspect Oriented Programming

;raphica% i%%ustration o& a s stem as a set o& concerns imp%emented - various modu%es

Cross)c#ttin" concerns In this" the methods used &or di&&erent concerns intersect. Hence crosscutting concerns span over mu%tip%e imp%ementation modu%es. A%though crosscutting concerns span over man modu%es" current imp%ementtation techniBues tend to imp%ement these reB uirements concentrating main% imp%ementation on the coree modu%e# %eve%

Aspect)oriente pro"rammin" 8AO!9 Is a ne1 techno%og &or separation o& crosscutting concerns into sing%e units ca%%ed aspects . 2he name Aspect Oriented Program ming 1as coined - Chris 6aeder o& =ero, Pa%eo A%to research Centre. Aspect Oriented Programming r evo%ves around the three &unctions Identi& concerns that cutt across c%ass @ o-Cect -oundaries Arite code 8an aspect: that encapsu%ates that concern De&ine a 1eave that speci&&ies ho1 the aspect 1i%% -e 1eaved into e,isting code

DEPT OF CSE,SDMCET, DHARWAD

Aspect Oriented Programming

Aspects An aspect is a modu%ar unit o& crosscutting imp%ementation. It encapsu%ates -ehaviors that a&&ect mu%tip%e c%asses into reusa-%e modu%es. An aspect is a piece o& code that descri-es a recurring propert o& a program. App%ications can" have mu%tip%e aspects. Aspects provide crosscutting modu%arit . In other 1ords" programmers can use aspects to create so&t1are modu%es &or issues that cut across various parts o& an app%ication. Aspect modu%es do not stand on their o1nD the &unction on% as add#on code that deve%opers can 1eave into app%ications.

0. Imp:ications o+ cross)c#ttin" concerns


A%though crosscutting concerns span over man modu%es" current imp%ementation techniBues tend to imp%ement these reBuirements concentrating main% on the core modu%e# %eve% imp%ementation. 2he remaining reBuirements are tagged a%ong this main dominant dimension. 2his resu%ts in an a191ard reBuirements#to# imp%ementation map. S%mptoms A &e1 s mptoms can indicate a pro-%ematic imp%ementation o& crosscutting concerns using current methodo%ogies. 2hose s mptoms can -e -road% c%assi&ied into t1o categories3 Co e tan":in"6odu%es in a so&t1are s stem ma simu%taneous% interact 1ith severa% reBuirements. Eor e,amp%e" o&ten deve%opers simu%taneous% thin9 a-out -usiness %ogic" per&ormance" S nchroni0ation" %ogging and securit . Such a mu%titude o& reBuirements resu%ts in the simu%taneous presence o& e%ements &rom each concern?s imp%ementation" resu%ting in code tang%ing. Co e scatterin"Since crosscutting concerns" - de&inition" spread over man modu%es" re%ated imp%ementations a%so spread over a%% those modu%es. Eor e,amp%e" in a s stem using a data-ase" per&ormance concerns ma a&&ect a%% the modu%es accessing the data-ase. Imp:ications Com-ined" code tang%ing and code scattering a&&ect so&t1are design and deve%opments in man 1a s3
6

DEPT OF CSE,SDMCET, DHARWAD

Aspect Oriented Programming

!oor tracea$i:it%Simu%taneous% imp%ementing severa% concerns o-scures the correspondence -et1een a concern and its imp%ementation" resu%ting in a poor mapping -et1een the t1o. Lo;er pro #cti/it%Simu%taneous imp%ementation o& mu%tip%e concerns shi&ts the deve%oper?s &ocus &rom the main concern to the periphera% concerns" %eading to %o1er productivit . Less co e re#seSince" under these circumstances" a modu%e imp%ements mu%tip%e concerns" other s stems reBuiring simi%ar &unctiona%it ma not -e a-%e to readi% use the modu%e" &urther %o1ering productivit . !oor co e <#a:it%Code tang%ing produces code 1ith hidden pro-%ems. 6oreover" - targeting too man concerns at once" one or more o& those concerns 1i%% not receive enough attention. More i++ic#:t e/o:#tionA %imited vie1 and constrained resources o&ten produce a design that addresses on% current concerns. Addressing &uture reBuirements o&ten reBuires re1or9ing the imp%ementation. Since the imp%ementation is not modu%ari0ed" that means touching man modu%es" modi& ing each su-s stem &or such changes can %ead to inconsistencies. It a%so reBuires considera-%e testing e&&ort to ensure that such imp%ementation changes have not caused -ugs 2hese are the imp%ications o& cross cutting concerns. 2he s mptoms o& cross concerns %i9e code scattering and code tang%ing negative% a&&ects the code e&&icienc " and sca%a-i%it .

=. AO! e/e:opmenta: sta"esAOP imp%ements individua% concerns in a %oose% coup%ed &ashion" and com-ine these imp%ementations to &orm the &ina% s stem. Indeed" AOP creates s stems using %oose% coup%ed" modu%ari0ed imp%ementations o& crosscutting concerns. AOP invo%ves three distinct deve%opment steps3 Aspect#a: ecomposition- Decompose the reBuirements to identi& crosscutting and common concerns. Separate modu%e#%eve% concerns &rom crosscutting s stem# %eve% concerns. Concern imp:ementation- Imp%ement each concern separate% .
7

DEPT OF CSE,SDMCET, DHARWAD

Aspect Oriented Programming

Aspect#a: recomposition- In this step" an aspect integrator speci&ies recom position ru%es creating modu%ari0ation units ## aspects. 2he recomposition process" a%so 9no1 n as 1eaving or integrating, uses this in&ormation to compose the &ina% s stem.

2. Anatom% o+ AO! :an"#a"es


An AOP imp%ementation consis ts o& t1o parts3 a %anguage speci&ication and an imp%ementation. 2he %anguage speci&ication descri-es %anguage constructs and s nta,. 2he %anguage imp%ementation veri&ies the code?s correctness according to the %anguage s peci&ication and converts it into a &orm that the target machine can e,ecute. T,e AO! :an"#a"e speci+ication At a higher %eve%" an AOP %angu age speci&ies t1o components3 Imp:ementation o+ concerns- 6apping an individua% reBuirement into code so tha t a compi%er can trans%ate it into e,ecuta-%e code. Since imp%ementation o& concerns ta9es the &orm o&

speci& ing procedures" it can -e used 1ith traditiona% %anguages %i9e C" CFF" or Java 1ith AOP. >ea/in" r#:es speci+ication- 2his speci&ies ho1 to compose independent% imp%emented

concerns to &orm the &ina% s ste m. Eor this purpose" an imp%ementation needs to use or create a %anguage &or speci& ing ru%es &o r composing di&&erent imp%ementation pieces to &orm the &ina% s stem. 2he %anguage &or speci& ing 1eaving ru%es can -e an e,tension o& th e imp%ementation %anguage.
8

DEPT OF CSE,SDMCET, DHARWAD

Aspect Oriented Programming

3. AO! :an"#a"e Imp:ementation


AOP %anguage compi%ers per&orm t1o %ogica% steps3 Com-ine the individua% concerns Convert the resu%ting in&ormation into e,ecuta-%e code An AOP imp%ementatio n can imp%ement the 1eaver in various 1a s" inc%uding source#to# source trans%ation. Here the source code is pre#processed &or individua% aspects to produce 1eaved source code. 2he AOP compi%er then &eeds this converted code to the -ase %anguage compi%er to produce &ina% e,ecuta-%e code.

4. C#rrent:% #se AO! too:s


AO! too:sAspectJ is one o& the high% avai%a-%e AOP %anguages. AspectJ is a genera%#purpose AO e,tension to Java" deve%oped - =ero, Pa%o A%to /esearch Center. Another AOP %anguage is H per@J" 1hich supports mu%tidimensiona% separation o& concerns. AspectC and AspectCFF are other AOP too%s. ?asic Lan"#a"e Constr#cts in Aspect. AspectJ is a %inguistic#-ased AOP %anguage. It is de&ined - a set o& %anguage constructs3 a Coin point" pointcuts" advice" introduction and aspects. A Coin point is a 1e%%#de&ined point in the &%o1 o& a program. Point cuts" se%ect particu%ar Coin points - &i%tering out a su-set o& a%% Coin points" -ased on de&ined criteria. Point cuts are used in the de&inition o& advice. An advice in AspectJ is used to de&ine additiona% code that shou%d -e e,ecuted at Coin points. An introduction in AspectJ introduces ne1 mem-ers to c%asses and there&ore changes inheritance re%ationship -et1een c%asses. Gn%i9e advices" introduction ta9es e&&ect at the compi%ation time. Introduction is a use&u% construct 1hen 1e 1ant to add ne1 concern to some e,isting c%asses" et 1e 1ant to have c%ear separation o& these crosscutting concerns. In AspectJ" an aspect is dec%ared - a 9e 1ord Haspect Hand is de&ined in terms o& point cuts" advice" and introductions. On% aspects ma inc%ude advice.
9

DEPT OF CSE,SDMCET, DHARWAD

Aspect Oriented Programming

(. E@amp:e co e +or an Aspect ;ritten in Aspect.


aspect PublicErrorLogging {Log log = new Log( ! pointcut public"alls ( #calls(public $ co%&'ero'&printers&$&$(&& ! a(ter( t)rowing (Error e # public*nter(ace( {log&write(e !+

2his code segment sho1s one 1a in 1hich aspect#oriented programming %ets deve%opers 1rite an aspect" a recurring so&t1are issue" once and have it appear 1herever needed. 2he segment ins tructs a%% pu-%ic methods o& the com.,ero,.printers so&t1are to %og their errors. 2he &ourth %ine indicates that the aspect app%ies to ca%%s to an methods. pu-%ic method in the com.,ero,.printers pac9age. It instructs the AOP compi%er to 1eave the aspect into a%% pu-%ic

*'.AO! $ene+its
AOP he%ps overcome the a&orementioned pro-%ems caused - code tang%ing and code scattering. 2hese are the speci&ic -ene&its AOP o&&er3 Mo #:ariAe imp:ementation o+ crossc#ttin" concernsAOP addresses each concern separate% 1ith minima% coup%ing" resu%ting in modu%ari0ed imp%ementations even in the presence o& crosscutting concerns. Such an imp%ementation produces a s stem 1ith %ess dup%icated code. Since each concern?s imp%ementation is separate" it a%so he%ps reduce code c%utter. Eurther" modu%ari0ed imp%ementation a%so resu%ts in a s stem that is easier to understand and maintain. Easier)to)e/o:/e s%stemsSince the aspected modu%es can -e una1are o& crosscutting concerns" it?s eas to add ne1er &unctiona%it - creating ne1 aspects. Eurther" 1hen ne1 modu%es are added to a s stem" the e,isting aspects crosscut them" he%ping create a coherent evo%ution. Late $in in" o+ esi"n ecisionsAith AOP" an architect can de%a ma9ing design decisions &or &uture reBuirements" since it can -e imp%emented as separate aspects.
1,

DEPT OF CSE,SDMCET, DHARWAD

Aspect Oriented Programming

more co e re#se>ecause AOP imp%ements each aspect as a separate modu%e" each individua% modu%e is more %oose% coup%ed. In genera%" a %oose% coup%ed imp%ementation" 1hich can -e o-tained - using AOP" represents the 9e to higher code reuse.

**.Conc:#sion
AOP introduces a ne1 st %e o& decomposition and is a promising 1a o& separating crosscutting concerns that are usua%% hard to do in o-Cect#oriented programming. AOP is particu%ar% use&u% in separating concerns that are uni#directiona% and have 1e%%#de&ined e&&ect" such as de-ugging and tracing concerns. Ho1ever" the current AOP techno%og is sti%% in research stage. Current% " three AOP research areas are important3 +ase o& use. 2echniBues on ho1 to understand a s stem in term o& aspects shou%d -e 1e%% documented. ;uide%ines and design princip%es" such as G65 &or AOP" AOP design patterns" must a%so -e esta-%ished. 2he he%p reduce the cost &or so&t1are engineers to
adapt to this ne1 paradigm.

Studies and e,periment that prove the use&u%ness o& AOP - measura-%e -ene&its. 2his encourages the computer industr giants and in&%uentia% committees to endorse the
techno%og .

Deve%opment too%s &or discovering aspects" restructuring e,isting codes" recutting" etc. AOP techno%og 1i%% on% -e adapted - the so&t1are industr .
2hose three &actors are signi&icant to determine 1hether i& the so&t1are industr 1i%%

eventua%% adapt AOP techno%og .

*&.Re+erences
111.parc.,ero,.com@cs%@proCects@aop@ 111.ccs.edu@home@%ie-er@connection#to#aop.htm% 111.aspectC.org@ 111.aosd.net@ 111.research.i-m.com@h perspace@H perJ@H perJ.htm 111.in&ormati9.uni#siegen.de@Imira

)ttp#--en&wi.ipe/ia&org-wi.i-0spect1oriente/1progra%%i ng

1 1

DEPT OF CSE,SDMCET, DHARWAD

You might also like