Metodologas de Desarrollo de Software Ciclo de Vida







![Sw Development Problems class Book. Store { private Book [] books ; private Partner Sw Development Problems class Book. Store { private Book [] books ; private Partner](https://slidetodoc.com/presentation_image_h2/ccfe0281e18a3c03793840d3adf68357/image-8.jpg)



























![Other Implementations • @Pointcut("<pointcut-kind>( [<accessspecifier>] <return-type> <classname>. <method-name>({<arg-type>}) )")public void <pointcut-name>() {. . . Other Implementations • @Pointcut("<pointcut-kind>( [<accessspecifier>] <return-type> <classname>. <method-name>({<arg-type>}) )")public void <pointcut-name>() {. . .](https://slidetodoc.com/presentation_image_h2/ccfe0281e18a3c03793840d3adf68357/image-36.jpg)















- Slides: 51

Metodologías de Desarrollo de Software (Ciclo de Vida) Juan Carlos Olivares Rojas MSN: juancarlosolivares@hotmail. com jcolivar@itmorelia. edu. mx http: //antares. itmorelia. edu. mx/~jcolivar/ @jcolivares Social Network: Facebook, Linked. In. Hi 5

Agenda • Introduction • Aspect-Oriented Programming Fundamentals • Examples

Software Development Today

Evolución del SW Software Evolution

Evolución del SW Software Evolution

Sw Development Problems • A complex system can visualize like as combined implementation of multiple concerns

Sw Development Problems class Book { …. . <all things about book> <error handling> … } class Partner { …. . <all things about Partner> <error handling> <access controlling> } class Rent {…. . <all things about Rent> <error handling> <access controlling> }
![Sw Development Problems class Book Store private Book books private Partner Sw Development Problems class Book. Store { private Book [] books ; private Partner](https://slidetodoc.com/presentation_image_h2/ccfe0281e18a3c03793840d3adf68357/image-8.jpg)
Sw Development Problems class Book. Store { private Book [] books ; private Partner [] partners; public Book. Store() { … public void load( Partner p, Book b) { if valid. Control. Access() then{ // code of the method } else{ throw. Exception(); } } Access Control public void add. Partner(Partner p){ if valid. Contol. Access() then{ // code of the method } else{ throw. Exception(); } } // the rest of the class methods }

Tyranny of the Dominant Decomposition • • Descomposition by Form, Color or size We must choose only one principal model

Tyranny of the Dominant Decomposition • Order by Form • Order by Color

Color-Form Hierarchy • We must elect one principal model. In this case: color and later, form

AOP Definition • AOP was created by Gregor Kickzales and his Research Team at Palo Alto Research Center in 1996. • “ An Aspect is a modular unit that is spreand in another functional units. The aspects exist in the design stage as in the implementación stage…” • An Aspect is a concept that it’s difficult encapsulate clear and easily.

AOP • An aspect is the unit which encapsulate a cross -cutting concern. • AOP promoves the separation of concerns through mechanisms which abstract and compose this concepts troughout the system.

Traditional Structure of a Compiler

Compiling Process in POA

AOP Program Structure Object Models Memory Managment Aspect Sincronization Aspect Program Error Handling ASpect Distribution Aspect …

AOP Program Structure

AOP Advantages

POA Concepts Join. Pointcut Advice Aspect It’s a well-defined position inside of object-oriented code, for instance, the declaración of a method. It’s a set of conditions applied to a Join. Point, when the conditions are true, it will active and execute an Execution Point asigned at this Point. Cut. It’s a Fragment of Code tha it’s executed when is actived Point. Cut. It’s the combination of Join. Point, Pointcuts and Advices.

Highlevel View of Aspect. J Advice advice body pointcut join point Java Program

An Aspect Definition Aspect Control { Join. Point security. Operations = call s Book. Store. loan & calls Book. Store. add. Partner&. . . Before security. Operations: { if !=(valid. Control. Acces()) then{ throws. Excepcion(); } }

AOP and OOP Relation OOP: common concerns AOP: crosscuting concerns Class A 1 Attb 1 Clase A 2 Attb 3 Attb 2 Method 1 Method 2

OOP Evolution to AOP

AOP vs OOP

POA Advantages • A code less complicated, more natural and more reduced. • More facilities to think about the concerns, since they are separate and dependencies between them are minimal. • An easier code to debug and to mantein.

AOP Tools • Langauges for Programming Aspects: • Aspect. J: A Java Extension. The most popular. • Aspect. C++, Aspect. S, CAESAR. • . NET Languages: Weave. NET, Source Weave.

Class Bank Problem public class Bank { // other declarations public double process. Debit(long id. Account, double amount) { // openning a transaction try { // retrieve account // business validation // business logic associated with debit // persistencia del nuevo estado // traceo del movimiento para auditoria // cierre exitoso de la transacción (commit) return new amount account; } catch (Exception e) { // trace the audit exception // close abnormal transaction (rollback) // relauch the exception in superior layers } } // other business process declarations } Transaction Persistence Traceability

Aspectual Descomposition • Separation of concerns • Aims to isolate cross cutting concerns • Each one of these concerns will be implemented in a separate unit.

Aspectual Recomposition

AOP Bank Version ac cio n an s nc ste ad ilid ab // another business methods declarations } Pe rsi } Tr az // validaciones del negocio // debit business logic return new amount account; ia Tr public double process. Debit(long account, double amount) { ali da d public class Bank { // other declarations

Logging in org. apache. tomcat logging is not modularized • where is logging in – red shows lines of code that handle logging – not in just one place – not even in a small number of places

Hello World with Aspects package mx. edu. itmorelia. aspects; public class HW { private String message; public HW() { this. message = “Hello World"; } public void set. Messge(String M){ this. menssage = M; } public String get. Message(){ return this. message; } public void show. Message(){ System. out. println(this. message); } }

Hello World with Aspects package mx. edu. itmorelia. aspects; public class Hello. World { public static void main(String[] args) { HW H; H= new HW(); H. show. Menssage(); } }

Hello World with Aspects package mx. edu. itmorelia. aspects; public aspect Aspect { pointcut messages. To. Print() : call (void HW. show. Message()); before(): messages. To. Print(){ System. out. println(“Hi everybody!"); } after(): messages. To. Print(){ System. out. println(“Chao everybody!"); } }

Other Implementations • import org. aspectj. lang. annotation. Aspect; • @Aspect • public class Aspecto {. . . } • @<advice-specification>("<pointcut-kind>( [<access-specifier>] <return-type> <classname>. <method-name>({<arg-type>}) )")public void metodo() {. . . }
![Other Implementations Pointcutpointcutkind accessspecifier returntype classname methodnameargtype public void pointcutname Other Implementations • @Pointcut("<pointcut-kind>( [<accessspecifier>] <return-type> <classname>. <method-name>({<arg-type>}) )")public void <pointcut-name>() {. . .](https://slidetodoc.com/presentation_image_h2/ccfe0281e18a3c03793840d3adf68357/image-36.jpg)
Other Implementations • @Pointcut("<pointcut-kind>( [<accessspecifier>] <return-type> <classname>. <method-name>({<arg-type>}) )")public void <pointcut-name>() {. . . } • @<advice-specification>("<pointcut-name>()") • public void metodo() {. . . }

Other Implementations @Before("execution(public paquete. clase. metodo(String))") public void advice. Ejemplo() System. out. println("Antes del metodo"); } void {

Other Implementations @Pointcut("execution(public paquete. clase. metodo(String))") public void pointcut. Ejemplo() {} @Before("pointcut. Ejemplo()") public void advice. Ejemplo() System. out. println("Antes del metodo"); } void {

Alternatives to Aspects • Languages (OO, Componet-Based) • Design Patterns • Reflection

Point. Cut

Point. Cut • When a particular method is executed: – execution(void Point. set. X(int)) • When a method is invocated: call(void Point. set. X(int)) • When a error handling is invocated: handler(Array. Out. Of. Bounds. Exception) • When the object is actually executed: this(Some. Type).

Point. Cut Examples • When a method belongs to a class: – within(My. Class) • When the Join. Point is in the control flow of a call main method we need to use: cflow • The target point refers to any possible Join. Point 42

Pointcut Designator Wildcards • It’s possible to use wildcards • What do the next instructions do? – – – execution(* *(. . )) call(* set(. . )) execution(int *()) call(* set. Y(long)) call(* Point. set. Y(int)) call(*. new(int, int)) 43

Point. Cut call join points a Line dispatch execution join points • Join. Point Types – Methods – Constructors – Get/Set – Exception Handler

Point. Cut Examples • We can applicate the next operations: or (“||”), and (“&&”) and not (“!”). • Examples: – – target(Point) && call(int *()) call(* *(. . )) && (within(Line) || within(Point)) within(*) && execution(*. new(int)) !this(Point) && call(int *(. . ))

Advice Type • before advice • after advice • after returning • after throwing • around advice 46

Parameterized Advice • We can acces to the context of a Join. Point as follow: • pointcut set. XY(Figure. Element fe, int x, int y): call(void Figure. Element. set. XY(int, int)) && target(fe) && args(x, y); • after(Figure. Element fe, int x, int y) returning: set. XY(fe, x, y) { System. out. println(fe + " moved to (" + x + ", " + y + "). "); } 47

Another Example Display * Figure. Element Figure make. Point(. . ) make. Line(. . ) Point get. X() get. Y() set. X(int) set. Y(int) move. By(int, int) 2 Line get. P 1() get. P 2() set. P 1(Point) set. P 2(Point) move. By(int, int) History. Updating

Another Example HTTPRequest get. Cookies() get. Request. URI()(doc) get. Session() get. Requested. Session. Id(). . . Session. Interceptor request. Map(request) before. Body(req, resp). . . Session get. Attribute(name) set. Attribute(name, val) invalidate(). . . HTTPResponse get. Request() set. Content. Type(content. Type) get. Outptut. Stream() set. Session. Id(id). . . 49 Servlet

References • Mejía, P. (2008), Programación Orientada a Aspectos, CINVESTAV, México. • Quintero, A. (2000), Visión General de la Programación Orientada a Aspectos. Languages and Information System Department. Informatic and Estadistic Faculty, Sevilla University, Spain. • Rodriguez M. , POA, Gerente Relaciones Académicas, Microsoft Cono Sur

¿Preguntas?