Aspect oriented programming



Download 251.43 Kb.
Page1/3
Date06.08.2017
Size251.43 Kb.
  1   2   3
A

Seminar report

On

ASPECT ORIENTED PROGRAMMING

Submitted

In Partial Fulfillment

For The Award of the Degree Of

BACHELOR OF TECHNOLGY




In Information Technology




Submitted To: Submitted By:

Mr. Shiv Kumar Agarwal Sudhanshu Mathur

Head Of Department Roll no:IT08059

Department Of I.T.

DEPARTMENT OF INFORMATION TECHNOLOGY

JAIPUR ENGINEERING COLLEGE, KUKAS

RAJASTHAN TECHNICAL UNIVERSITY

A

Jaipur Engineering College, Kukas,

Jaipur

SESSION 2011-2012






CERTIFICATE

This is to certify that project entitled “Aspect oriented programming”, submitted by “Sudhanshu Mathur”, students of final year B.Tech in Information Technology, JAIPUR ENGINEERING COLLGE, KUKAS, JAIPUR was completed under my supervision and their work was found satisfactory and I found them sincere towards their work.

Signature

Mr.Shiv Agarwal

Head, Department of IT

Place: - Jaipur

Date: - 14/03/2012

Preface

This report intends to reflect some of the basics required for building a project i.e. “Aspect oriented programming and related fundamentals”. The total aspects have been formulated and presented on the basis of ideas and information gathered from emerging technology.

This report has been written in response to a comprehensive study. The report mentions and evaluates the various aspects, through analysis of the various facts and figures. Accuracy and precision has been given prime consideration, while compiling the report.

ACKNOWLEDGEMENT

Let me in this page express my heartiest gratitude to all those who helped me in various stages of this study. I am very much thankful to Dr. G.D.SHARMA, Director (Academics), JEC College, Kukas, and Mr. Shiv Kumar Agarwal, HOD, Dept. Of IT for giving me permission to undergo the seminar and providing all other necessary facility. I would also thankful to Mr. Manoj Raman and Ms Anuradha, Sr. Faculty of IT department for their kind support.

During the seminar period all the staff member of Deptt. have helped me with there skills. Here by I express my sincere thanks to seminar coordinator. Also I am thankful to other technical staff of the Deptt. who have helped me to complete my seminar successfully. I wish to express my deep sense of gratitude to my seminar guide for her valuable guidance and kind cooperation without which this project would have not been possible.

Sudhanshu Mathur (IT08059)

IT Department



Jaipur Engineering College



CHAPTER

NAME OF THE CHAPTER

PAGE NO

1.

INTRODUCTION

02

2

GOALS OF ASPECT ORIENTED PROGRAMMING

04

3

TERMINOLOGY


3.1

CROSS CUTTING CONCERNS

07

3.2

ASPECT

08

3.3

ADVICE

08

3.4

JOIN-POINT

09

3.5

POINT-CUT

10






07

4

OVERVIEW OF ASPECT ORIENTED PROGRAMMING

11

5

ARCHITECTURE OF AOP

13

6

MOTIVATION AND BASIC CONCEPTS

14

7

ASPECT-J

17

8

COMPARISION TO OTHER PROGRAMMING PARADIGMS

22

9

ADVANTAGES & DISADVANTAGES

23

10

CONCLUSION

24

INDEX

ABSTRACT

 In software engineering, the programming paradigms of Aspect- Oriented 
programming (AOP), and Aspect- Oriented Software development (AOSD) attempt to aid programmers in the separation of concerns, specifically cross-cutting concerns, as an advance in modularization. AOP does so using primarily language changes, while AOSD uses a combination of language, environment, and method. Separation of concerns entails breaking down a program into distinct parts that overlap in functionality as little as possible. All programming methodologies including procedural programming and object-oriented programming support some separation and encapsulation of concerns (or any area of interest or focus) into single entities. For example, procedures, packages, classes, and methods all help programmers encapsulate concerns into single entities. But some concerns defy these forms of encapsulation. Software engineers call these crosscutting concerns, because they cut across many modules in a program. Logging offers one example of a crosscutting concern, because a logging strategy necessarily affects every single logged part of the system. Logging thereby crosscuts all logged classes and methods. AOP is a new technology for separating crosscutting concerns into single units called aspects. An aspect is a modular unit of crosscutting implementation. It encapsulates behaviour that affects multiple classes into reusable modules. Typically, an aspect is scattered or tangled as code, making it harder to understand and maintain. It is scattered by virtue of the function (such as logging) being spread over a number of unrelated functions that might use its function, possibly in entirely unrelated systems, different source languages, etc. That means to change logging can require modifying all affected modules. Aspects become tangled not only with the mainline function of the systems in which they are expressed but also with each other. That means changing one concern entails understanding all the tangled concerns or having some means by which the effect of changes can be inferred.

Aspects emerged out of object-oriented programming and computational reflection. AOP languages have functionality similar to, but more restricted than metaobject protocols. Aspects relate closely to programming concepts like subjects, mixins, and delegation. Other ways to use aspect-oriented programming paradigms include Composition Filters and the hyperslices approach. Since at least the 1970s, developers have been using forms of interception and dispatch-patching that resemble some of the implementation methods for AOP, but these never had the semantics that the crosscutting specifications provide written in one place.



Designers have considered alternative ways to achieve separation of code, such as C#'s partial types, but such approaches lack a quantification mechanism that allows reaching several join points of the code with one declarative statement.

CHAPTER 1

INTRODUCTION

Aspect Oriented Programming (AOP) is a promising new technology for separating crosscutting concerns that are usually hard to do in object-oriented programming . Now-a-days, object-oriented programming (OOP) has become the mainstream programming paradigm where real world problems are decomposed into objects that abstract behavior and data in a single unit.OOP encourages software re-use by providing design and language constructs for modularity, encapsulation, inheritance, and polymorphism. Although OOP has met great success in modelling and implementing complex software systems, it has its problems. Practical experience with large projects has shown that programmers may face some problems with maintaining their code because it becomes increasingly difficult to cleanly separate concerns into modules. An attempt to do a minor change in the program design may require several updates to a large number of unrelated modules. AOP is a new technology for separating crosscutting concerns into single units called aspects. An aspect is a modular unit of crosscutting implementation. It encapsulates behaviors that affect multiple classes into reusable modules. With AOP, we start by implementing our project using our OO language (for example, Java), and then we deal separately with crosscutting concerns in our code by implementing aspects. Finally, both the code and aspects are combined into a final executable form using an aspect weaver. As a result, a single aspect can contribute to the implementation of a number of methods, modules, or objects, increasing both reusability and maintainability of the code.
In computing, Aspect-oriented-programming (AOP) is a programming paradigm which aims to increase modularity by allowing the separation of cross-cutting concerns. AOP forms a basis for aspect-oriented software development. AOP includes programming methods and tools that support the modularization of concerns at the level of the source code, while "aspect-oriented software development" refers to a whole engineering discipline.

Question arises that what actually computing is and what we have to do for that….

Computing is usually defined as the activity of using and improving computer hardware and software. It is the computer-specific part of information technology. Computer science (or computing science) is the study and the science of the theoretical foundations of information and computation and their implementation and application in computer systems.

Aspect-oriented programming entails breaking down program logic into distinct parts (so-called concerns, cohesive areas of functionality). Nearly all programming paradigms support some level of grouping and encapsulation of concerns into separate, independent entities by providing abstractions (e.g., procedures, modules, classes, methods) that can be used for implementing, abstracting and composing these concerns. But some concerns defy these forms of implementation and are called crosscutting concerns because they "cut across" multiple abstractions in a program.

Logging exemplifies a crosscutting concern because a logging strategy necessarily affects every logged part of the system. Logging thereby crosscuts all logged classes and methods.

All AOP implementations have some crosscutting expressions that encapsulate each concern in one place. The difference between implementations lies in the power, safety, and usability of the constructs provided. For example, interceptors that specify the methods to intercept express a limited form of crosscutting, without much support for type-safety or debugging. AspectJ has a number of such expressions and encapsulates them in a special class, an aspect. For example, an aspect can alter the behavior of the base code (the non-aspect part of a program) by applying advice (additional behavior) at variousjoin points (points in a program) specified in a quantification or query called a pointcut (that detects whether a given join point matches). An aspect can also make binary-compatible structural changes to other classes, like adding members or parents.


Starting from or! and other primitive filters, the programmer could work up to the definition of a filter that selects just those black pixels on a horizontal edge, returning a new image consisting of just those boundary pixels.

functionality

implementation


pixelwise logical operations

written using loop primitive as above


shift image up, down

written using loop primitive;

slightly different loop structure



difference of two images

(defun remove! (a b)

(and! a (not! b)))




pixels at top edge of a region

(defun top-edge! (a)

(remove! a (down! a)))




pixels at bottom edge of a region

(defun bottom-edge! (a)

(remove! a (up! a)))




horizontal edge pixels

(defun horizontal-edge! (a)

(or! (top-edge! a)



(bottom-edge! a)))

CHAPTER 2

GOALS OF AOP


Aspect-oriented programming (AOP) better separates concerns than previous 
methodologies, thereby providing modularization of crosscutting concerns. 
In the early days of computer science, developers wrote programs by means of direct machine-level coding. Unfortunately, programmers spent more time thinking about a particular machine's instruction set than the problem at hand. Slowly, we migrated to higher-level languages that allowed some abstraction of the underlying machine. Then came structured languages; we could now decompose our problems in terms of the procedures necessary to perform our tasks. However, as complexity grew, we needed better techniques. Object-oriented programming (OOP). Let us view a system as a set of collaborating objects. Classes allow us to hide implementation details beneath interfaces. Polymorphisms provided a common behavior and interface for related concepts, and allowed more specialized components to change a particular behaviour without needing access to the implementation of base concepts. Programming methodologies and languages define the way we communicate with machines. Each new methodology presents new ways to decompose problems: machine code, machine-independent code, procedures, classes, and so on. Each new methodology allowed a more natural mapping of system requirements to programming constructs. Evolution of these programming methodologies let us create systems with ever increasing complexity. The converse of this fact may be equally true: we allowed the existence of ever more complex systems because these techniques permitted us to deal with that complexity. Aspect-oriented programming (AOP) better separates concerns than previous methodologies, thereby providing modularization of crosscutting concerns.


Good modularity XML parsing

tc2

Figure 1

  • URL pattern matching in org.apache.tomcat

    • red shows relevant lines of code

    • nicely fits in two boxes (using inheritance)

Good modularity URL pattern matching

tc3

Figure 2

  • URL pattern matching in org.apache.tomcat

    • red shows relevant lines of code

    • nicely fits in two boxes (using inheritance)

Implications of Non-modularization

  • 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

    • and be sure not to break it by accident


CHAPTER 3

TERMINOLOGY


Before we delve too deeply into AOP, let's introduce some terminology to help us understand the concepts. 
Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.

Advice: This is the additional code that you want to apply to your existing model. In our example, this is the logging code that we want to apply whenever the thread enters or exits a method. 

Point-cut: This is the term given to the point of execution in the application at which cross-cutting concern needs to be applied. In our example, a point-cut is reached when the thread enters a method, and another point-cut is reached when the thread exits the method.

Aspect: The combination of the point-cut and the advice is termed an aspect. In the example below, we add a logging aspect to our application by defining a point-cut and giving the correct advice. Aspects should have the following properties: robust (change to one aspect should have a limited impact on other aspects), systemic (they affect the target program at many different places), cross-cutting each other (in the target program information about one aspect is mixed with information about other aspects), loosely coupled (an aspect should not know the details of other aspects), contain join points (which are used to combine the aspects).

CROSS- CUTTING CONCERNS
Separation of concerns entails breaking down a program into distinct parts that overlap in functionality as little as possible. All programming methodologies including procedural programming and object-oriented programming support some separation and encapsulation of concerns (or any area of interest or focus) into single entities. For example, procedures, packages, classes, and methods all help programmers encapsulate concerns into single entities. But some concerns defy these forms of encapsulation. Software engineers call these crosscutting concerns, because they cut across many modules in a program.
An example of crosscutting concerns is "logging," which is frequently used in distributed applications to aid debugging by tracing method calls. Suppose we do logging at both the beginning and the end of each function body. This will result in crosscutting all classes that have at least one function. Other typical crosscutting concerns include context-sensitive error handling, performance optimization, and design patterns. Crosscutting concerns may exist in some programs, especially large ones. However, in some situations, redesign of the system might transform a crosscutting into an object. AOP assumes that crosscutting concerns may exist in programs and can't be re-factored out of the 
design in all situations.


Download 251.43 Kb.

Share with your friends:
  1   2   3




The database is protected by copyright ©ininet.org 2020
send message

    Main page