1 / 8

Survey of Aspect-Oriented Programming

Survey of Aspect-Oriented Programming. Neerja Bhatnagar. CS 203 Programming Languages Fall 2004. Motivation for AOP. Code continues to grow in size and complexity Code evolves to become unmodularized, and hence unclean Application logic gets intermingled with system code

ryann
Download Presentation

Survey of Aspect-Oriented Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Survey of Aspect-Oriented Programming Neerja Bhatnagar CS 203 Programming Languages Fall 2004

  2. Motivation for AOP • Code continues to grow in size and complexity • Code evolves to become unmodularized, and hence unclean • Application logic gets intermingled with system code • For example, business logic of processing credit card payment intermingled with code that logs the transaction • AOP aims to improve software design and development via separation of concerns

  3. Conventional Logging • Does not utilize aspects • Utilizes java.util.logging import java.util.logging.*; … static Logger logger = Logger.getLogger(“Log”); … public void setEmployeeAddress(String address) { if (name != null) { logger.logp(Level.INFO, “Employee”, “setEmployeeAddress”, “Address Changed”); employeeAddress = address; } } …

  4. import org.aspectj.lang.* import java.util.logging.*; public aspect AspectLog { Logger logger = Logger.getLogger(“Log”); // specify point of execution for // logging. within matches methods pointcut logMethods(): execution(* *.*(..)) && within(AspectLog); // begin logging before reaching // join point before():logMethods() { … } … Java code remains unchanged! public class Employee { public Employee() { … } … setEmployeeAddress(String address) { … } … } Logging with Aspects • Push functionality related to logging into aspect(s) • Application logic remains unchanged.

  5. AOP Languages and Frameworks Languages • AspectJ (Aspects for Java) • AspectC++ (Aspects for C++, may be C) • Weave.NET (Language Independent Aspects) Frameworks • Nanning (for Java) (http://nanning.codehaus.org) • AspectWerkz (for Java) (http://aspectwerkz.codehaus.org) • JBoss (for Java) (http://www.jboss.org) • HyperJ (for Java) (www.research.ibm.com/hyperspace/hyperj) • Others – abc, AspectC#, CLAW, AOP#, AspectDNG

  6. AOP Terminology (Buzzwords) public class Employee { public String employeeName; … public Employee() {…} public void setEmployeeName(String name) { if (name != null) { logger.logp(Level.INFO, "Employee", "setEmployeeName", "Name change"); employeeName = name; } } … } Point Cut Crosscutting concern Join Point

  7. AOP Terminology (Buzzwords), contd. Aspect import org.aspectj.lang.* import java.util.logging.*; public aspectAspectLog { Logger logger = Logger.getLogger(“Log”); // specify point of execution for // logging. within matches methods pointcut logMethods(): execution(* *.*(..)) && within(AspectLog); // code that actually logs … // begin logging before reaching // join point before():logMethods() { … } … Advice

  8. Thank You

More Related