metodologías de desarrollo de software (ciclo de vida)
DESCRIPTION
Metodologías de Desarrollo de Software (Ciclo de Vida). Juan Carlos Olivares Rojas. MSN: [email protected] [email protected] http://antares.itmorelia.edu.mx/~jcolivar/ @jcolivares Social Network: Facebook, LinkedIn. Hi5. Agenda. Introduction - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/1.jpg)
Metodologías de Desarrollo de Software (Ciclo de Vida)
Juan Carlos Olivares Rojas
MSN: [email protected]@itmorelia.edu.mx
http://antares.itmorelia.edu.mx/~jcolivar/@jcolivares
Social Network: Facebook, LinkedIn. Hi5
![Page 2: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/2.jpg)
Agenda• Introduction
• Aspect-Oriented Programming Fundamentals
• Examples
![Page 3: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/3.jpg)
Software Development Today
![Page 4: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/4.jpg)
Evolución del SWSoftware Evolution
![Page 5: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/5.jpg)
Evolución del SWSoftware Evolution
![Page 6: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/6.jpg)
Sw Development Problems
• A complex system can visualize like as combined implementation of multiple concerns
![Page 7: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/7.jpg)
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>
}
![Page 8: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/8.jpg)
class BookStore { private Book [] books ; private Partner [] partners; public BookStore() { … public void load( Partner p, Book b) { if validControlAccess() then{ // code of the method } else{ throwException(); } }
public void addPartner(Partner p){ if validContolAccess() then{ // code of the method } else{ throwException(); } }// the rest of the class methods}
Access ControlAccess Control
Sw Development Problems
![Page 9: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/9.jpg)
Tyranny of the Dominant Decomposition
• Descomposition by Form, Color or size• We must choose only one principal model
![Page 10: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/10.jpg)
Tyranny of the Dominant Decomposition
• Order by Form
• Order by Color
![Page 11: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/11.jpg)
Color-Form Hierarchy• We must elect one principal model.
In this case: color and later, form
![Page 12: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/12.jpg)
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.
![Page 13: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/13.jpg)
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.
![Page 14: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/14.jpg)
Traditional Structure of a Compiler
Lenguaje
Compilador o Intérprete
EJECUTABLE
PROGRAMA
![Page 15: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/15.jpg)
Compiling Process in POA
... Lenguaje base
Lenguaje de aspectos 1
Lenguaje de aspectos N
... TEJEDOR (WEAVER)
EJECUTABLE
PROGRAMA DE ASPECTOS N
PROGRAMA DE ASPECTOS 1
PROGRAMA DE COMPONENTES
![Page 16: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/16.jpg)
ProgramProgram
AOP Program Structure
![Page 17: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/17.jpg)
AOP Program Structure
![Page 18: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/18.jpg)
AOP Advantages
![Page 19: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/19.jpg)
POA ConceptsJoinPoint It’s a well-defined position inside of
object-oriented code, for instance, the declaración of a method.
Pointcut It’s a set of conditions applied to a JoinPoint, when the conditions are true, it will active and execute an Execution Point asigned at this PointCut.
Advice It’s a Fragment of Code tha it’s executed when is actived PointCut.
Aspect It’s the combination of JoinPoint, Pointcuts and Advices.
![Page 20: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/20.jpg)
Highlevel View of AspectJ
Java Program
AspectJ
Advice
pointcutadvice body
join point
![Page 21: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/21.jpg)
An Aspect Definition
Aspect Control {
JoinPoint securityOperations = call s BookStore.loan & calls BookStore.addPartner& ...
Before securityOperations: {if !=(validControlAcces()) then{ throwsExcepcion(); }
}
![Page 22: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/22.jpg)
AOP and OOP Relation
Class A
Class A1
Attb1
Attb2
Method 1
Clase A2
Attb 3
Method 1
Method 2
OOP: common concerns
AOP: crosscuting concerns
![Page 23: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/23.jpg)
OOP Evolution to AOP
Own behavior Own behavior
Persistence
Trace
……..
Own Behavior Owbn Behavior
Persistence Trace
Class A Class B
Class A Class B
Classes
Aspects
![Page 24: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/24.jpg)
AOP vs OOP
![Page 25: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/25.jpg)
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.
![Page 26: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/26.jpg)
AOP Tools
• Langauges for Programming Aspects:
• AspectJ: A Java Extension. The most popular.
• AspectC++, AspectS, CAESAR.
• .NET Languages: Weave.NET, Source Weave.
![Page 27: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/27.jpg)
Class Bank Problem
public class Bank { // other declarations
public double processDebit(long idAccount, 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
![Page 28: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/28.jpg)
Aspectual Descomposition• Separation of concerns
• Aims to isolate cross cutting concerns
• Each one of these concerns will be implemented in a separate unit.
![Page 29: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/29.jpg)
Aspectual Recomposition
![Page 30: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/30.jpg)
AOP Bank Versionpublic class Bank { // other declarations
public double processDebit(long account, double amount) {
// validaciones del negocio // debit business logic return new amount account;}
// another business methods declarations}
Tran
sacc
iona
lidad
Pers
iste
ncia
Traz
abilid
ad
![Page 31: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/31.jpg)
Logging in org.apache.tomcat
• 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
logging is not modularized
![Page 32: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/32.jpg)
Hello World with Aspectspackage mx.edu.itmorelia.aspects;public class HW {
private String message; public HW() {
this.message = “Hello World";}public void setMessge(String M){
this.menssage = M;}public String getMessage(){
return this.message;}public void showMessage(){
System.out.println(this.message);}
}
![Page 33: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/33.jpg)
package mx.edu.itmorelia.aspects;
public class HelloWorld {public static void main(String[] args) {
HW H; H= new HW();H.showMenssage();
}}
Hello World with Aspects
![Page 34: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/34.jpg)
package mx.edu.itmorelia.aspects;
public aspect Aspect {pointcut messagesToPrint() : call (void HW.showMessage());
before(): messagesToPrint(){ System.out.println(“Hi everybody!"); }after(): messagesToPrint(){ System.out.println(“Chao everybody!"); }
}
Hello World with Aspects
![Page 35: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/35.jpg)
Other Implementations• import
org.aspectj.lang.annotation.Aspect;• @Aspect • public class Aspecto { ... }
• @<advice-specification>("<pointcut-kind>( [<access-specifier>] <return-type> <class-name>.<method-name>({<arg-type>}) )")public void metodo() { ... }
![Page 36: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/36.jpg)
Other Implementations• @Pointcut("<pointcut-kind>( [<access-
specifier>] <return-type> <class-name>.<method-name>({<arg-type>}) )")public void <pointcut-name>() { ... }
• @<advice-specification>("<pointcut-name>()")
• public void metodo() { ... }
![Page 37: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/37.jpg)
Other Implementations@Before("execution(public void
paquete.clase.metodo(String))")public void adviceEjemplo()
{ System.out.println("Antes del metodo"); }
![Page 38: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/38.jpg)
Other Implementations@Pointcut("execution(public void
paquete.clase.metodo(String))") public void pointcutEjemplo() {}
@Before("pointcutEjemplo()") public void adviceEjemplo()
{ System.out.println("Antes del metodo"); }
![Page 39: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/39.jpg)
Alternatives to Aspects
• Languages (OO, Componet-Based)
• Design Patterns
• Reflection
![Page 40: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/40.jpg)
PointCut
![Page 41: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/41.jpg)
PointCut• When a particular method is executed:
– execution(void Point.setX(int))
• When a method is invocated: call(void Point.setX(int))
• When a error handling is invocated: handler(ArrayOutOfBoundsException)
• When the object is actually executed: this(SomeType).
![Page 42: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/42.jpg)
42
PointCut Examples
• When a method belongs to a class:– within(MyClass)
• When the JoinPoint is in the control flow of a call main method we need to use: cflow
• The target point refers to any possible JoinPoint
![Page 43: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/43.jpg)
43
Pointcut Designator Wildcards
• It’s possible to use wildcards
• What do the next instructions do?– execution(* *(..)) – call(* set(..)) – execution(int *()) – call(* setY(long)) – call(* Point.setY(int)) – call(*.new(int, int))
![Page 44: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/44.jpg)
PointCut
• JoinPoint Types– Methods– Constructors– Get/Set– Exception Handler
a Line
dispatch
call join points
execution join points
![Page 45: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/45.jpg)
PointCut 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 *(..))
![Page 46: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/46.jpg)
46
Advice Type• before advice
• after advice
• after returning
• after throwing
• around advice
![Page 47: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/47.jpg)
47
Parameterized Advice• We can acces to the context of a
JoinPoint as follow:
• pointcut setXY(FigureElement fe, int x, int y): call(void FigureElement.setXY(int, int)) && target(fe) && args(x, y);
• after(FigureElement fe, int x, int y) returning: setXY(fe, x, y) { System.out.println(fe + " moved to (" + x + ", " + y + ").");}
![Page 48: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/48.jpg)
Another Example
HistoryUpdating
Display
*
2Point
getX()getY()setX(int)setY(int)moveBy(int, int)
Line
getP1()getP2()setP1(Point)setP2(Point)moveBy(int, int)
Figure
makePoint(..)makeLine(..)
FigureElement
moveBy(int, int)
![Page 49: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/49.jpg)
49
Another Example
HTTPRequest
HTTPResponse
Servlet
getCookies()getRequestURI()(doc)getSession()getRequestedSessionId()...
getRequest()setContentType(contentType)getOutptutStream()setSessionId(id)...
SessionInterceptor
requestMap(request)beforeBody(req, resp)...
SessiongetAttribute(name)setAttribute(name, val)invalidate()...
![Page 50: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/50.jpg)
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
![Page 51: Metodologías de Desarrollo de Software (Ciclo de Vida)](https://reader035.vdocumento.com/reader035/viewer/2022081504/56813e03550346895da7e0c9/html5/thumbnails/51.jpg)
¿Preguntas?