Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Modularization.

Slides:



Advertisements
Similar presentations
Component Oriented Programming 1 Chapter 2 Theory of Components.
Advertisements

Aspect Oriented Programming. AOP Contents 1 Overview 2 Terminology 3 The Problem 4 The Solution 4 Join point models 5 Implementation 6 Terminology Review.
An Aspect-Oriented Approach For Web Application Access Control Presented by: Mohamed Hassan Carleton University Carleton University
ASTA Aspect Software Testing Assistant Juha Gustafsson, Juha Taina, Jukka Viljamaa University of Helsinki.
University of British Columbia Software Practices Lab Fluid AOP Join Point Models Terry Hon Gregor Kiczales.
ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.
University of British Columbia Software Practices Lab CAS Seminar 06 Fluid AJ - A Simple Fluid AOP Tool Terry Hon Gregor Kiczales.
Karlstad University Computer Science Design Contracts and Error Management Design Contracts and Errors A Software Development Strategy (anpassad för PUMA)
Chapter 1 Principles of Programming and Software Engineering.
More on AspectJ. aspect MoveTracking { private static boolean _flag = false; public static boolean testAndClear() { boolean result = _flag; _flag = false;
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Subclasses and Subtypes CMPS Subclasses and Subtypes A class is a subclass if it has been built using inheritance. ▫ It says nothing about the meaning.
A Formal Model of Modularity in Aspect-Oriented Programming Jonathan Aldrich : Objects and Aspects Carnegie Mellon University.
Component-Based Software Engineering Components and Interfaces Paul Krause.
1 Aspects and Modularity: The Hope and the Challenge Jonathan Aldrich Institute for Software Research International School of Computer Science Carnegie.
Taming Obliviousness in Aspects with Data-flow Analysis and Design by Contract Tim Molderez and Dirk Janssens Ansymo Antwerp Systems and Software Modelling.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Debugging Support.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University ICSE 2003 Java.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech.
An Introduction to Software Architecture
1 Debugging and Testing Overview Defensive Programming The goal is to prevent failures Debugging The goal is to find cause of failures and fix it Testing.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University A Criterion for.
Aspect Oriented Programming Razieh Asadi University of Science & Technology Mazandran Babol Aspect Component Based Software Engineering (ACBSE)
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Change Impact Analysis for AspectJ Programs Sai Zhang, Zhongxian Gu, Yu Lin and Jianjun Zhao Shanghai Jiao Tong University.
1 Metamodel Access Protocols for Extensible Aspect-Oriented Modeling Naoyasu Ubayashi(Kyushu Institute of Technology, Japan) Shinji Sano(Kyushu Institute.
Aspect Oriented Programming Sumathie Sundaresan CS590 :: Summer 2007 June 30, 2007.
111 Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract,
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Methodology: The AOP Refactoring Process Aspect-Oriented Refactoring of the Apache Cocoon Shared-Object Resource Allocation System Jeff Dalton Advisor:
A Distributed Aspect-Oriented System for J2EE Applications Muga Nishizawa and Shigeru Chiba (Tokyo Institute of Technology, Japan) Background - As benefits.
AOSD1 Aspect-Oriented Software Design Karl Lieberherr Theo Skotiniotis.
AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.
CS Data Structures I Chapter 2 Principles of Programming & Software Engineering.
1 An Aspect-Oriented Implementation Method Sérgio Soares CIn – UFPE Orientador: Paulo Borba.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Assertion with.
IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.
Inter-Type Declarations in AspectJ Awais Rashid Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
Demeter Aspects We study techniques for the emerging area of Aspect-Oriented Software Development and focus on the following areas:  Aspectual Collaborations.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Debugging COMP T1.
1 Context-aware Feature-Oriented Modeling with an Aspect Extension of VDM Naoyasu Ubayashi (Kyushu Institute of Technology) Shin Nakajima (National Institute.
Towards an Aspect-oriented Language Module: Aspects for Petri Nets Tim Molderez, Bart Meyers, Dirk Janssens and Hans Vangheluwe Ansymo Antwerp Systems.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Extracting Sequence.
AOSD'04, Lancaster, UK 1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech) Shigeru Chiba (Tokyo Tech) Michiaki Tatsubori.
1 Separation of Context Concerns --- Applying Aspect Orientation to VDM Naoyasu Ubayashi (Kyushu Institute of Technology) Shin Nakajima (National Institute.
R R R A Brief Introduction to Aspect-Oriented Programming.
Refining the Use Cases 1. How Use Cases Evolve  Early efforts typically define most of the major use cases.  The refining stages complete the process.
Chapter 2 Principles of Programming and Software Engineering.
1 Aspectual Caml an Aspect-Oriented Functional Language Hideaki Tatsuzawa Hidehiko Masuhara Akinori Yonezawa University of Tokyo.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
Testing Overview Software Reliability Techniques Testing Concepts CEN 4010 Class 24 – 11/17.
PPL 2004, Gamagori, AICHI1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech, Japan) Shigeru Chiba (Tokyo Tech, Japan)
Principles of Programming & Software Engineering
Software Engineering Lecture 7
Design by Contract Jim Fawcett CSE784 – Software Studio
Design by Contract Jim Fawcett CSE784 – Software Studio
Chapter 11 Object-Oriented Design
Arab Open University 2nd Semester, M301 Unit 5
Principles of Programming and Software Engineering
Aspect-Oriented Programming with the Eclipse AspectJ plug-in
Demeter Aspects Who We Are Aspectual Collaborations
Presented by Igor Ivković
An Introduction to Software Architecture
AspectAda Aspect-Oriented Programming for Ada95
Assertions References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 4/25/2019.
Presentation transcript:

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Modularization of Assertion Crosscutting Objects Takashi Ishio † , Toshihiro Kamiya ‡ , Shinji Kusumoto † , Katsuro Inoue † † Osaka University ‡ National Institute of Advanced Industrial Science and Technology {t-isio, kusumoto,

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 2 Overview Assertion and Design by Contract Assertion crosscutting objects Example: Observer pattern with an inter-object constraint Our proposal: Aspect for Crosscutting Assertion Rewriting inter-object constraint using aspect Discussions Effect on software quality Related work

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 3 Assertion statement An assertion statement describes a condition must be true at the statement. Assertion Statement in Java: assert ( Boolean expression ); assert( true ) means the system works well. assert( false ) indicates a failure.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 4 Assertion as document Assertion placed before/after a program element is a part of documents for the element. An element: a statement, a code block or a method. assert(X); { // do something } assert(Y); assert(Z); Preconditions to be satisfied before the element is executed. Postconditions to be satisfied after the element is executed. execute

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 5 Effectiveness of assertion Explicit responsibility: Design by Contract Contract consists of pre/post-conditions for each method. Contract explicitly defines the responsibility of the module. Contract tells a developer the specification to be implemented. Early detection of a failure Assertion stops the system in invalid state before the system breaks important data. An assertion failure provides a hint for developers to debug the system.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 6 Assertion is effective. However … Assertion and Design by Contract Assertion crosscutting objects Example: Observer pattern with an inter-object constraint Aspect for Assertion Rewriting inter-object constraint using aspect Discussions Effect on software quality Related work

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 7 Example: Observer pattern Observer + update(); Subject + attach(observer); + detach(observer); attach update detach An observer attaches itself to a subject. When the state of a subject is updated, the subject calls update. An observer detaches itself from a subject if it no longer needs update notification.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 8 Relationship among Objects The pattern allows many-to-many relation. Several observers can watch one subject. An observer can watch several subjects. Observer 1 Observer 2 Observer 3 Observer 4 Subject 1 Subject 2 Subject 3

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 9 one subject-to-many observers constraint A constraint: one subject – to – many observers prohibits an observer attached to several subjects. This constraint is hard to describe in usual assertion. An observer has no information about attached subjects.  A subject cannot know whether an observer is already attached to other subjects. attached Observer 1 Observer 2 Subject 1 Subject 2

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 10 Implementation using traditional assertion This implementation adds the field “subject” recording an attached subject to Observer. Subject.attach checks and updates the field. Subject.detach method resets the field.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 11 Problem in this approach Broken encapsulation of Observer Only attach and detach methods of Subject can modify the subject field of Observer. An observer must not modify its field. Observer Subject subject read/write attach must not modify

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 12 Our approach Assertion and Design by Contract Assertion crosscutting objects Example: Observer pattern with an inter-object constraint Aspect for Assertion Rewriting inter-object constraint using aspect Discussions Effect on software quality Related work

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 13 Aspect for assertion Aspect modularizing crosscutting assertion We use our simple aspect-oriented language. We only need a subset of AspectJ to describe assertion. not the full set of AspectJ or other AOP implementation. For prototyping, we have developed a translator for our language to AspectJ.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 14 Our language construct Join Point Model AspectJ Join Point Model is suitable. Pre/post-conditions are usually checked before/after a method call. State-based join point model might make other model of assertion. Pointcut call pointcut is main construct. Context exposure is important. this, target, args pointcuts in AspectJ Because assertion usually access contextual information. We did not use other powerful pointcuts such as cflow. Evaluating effectiveness of such pointcuts is a future work.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 15 Advice and inter-type declaration Advice An advice can define pre-/post-conditions, and code blocks. Both pre-/post-conditions are usually defined for one pointcut. An advice might need to execute some code to record or to calculate data for assertion. Inter-type declaration Aspect needs additional fields and methods. Fields to record the inter-mediate state, Methods to inspect the complex state and to update fields.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 16 Constraint aspect for Observer Advice for Subject.detach (omitted) Inter-type declaration (AspectJ style) The beginning of aspect definition The end of aspect definition Advice for Subject.attach (Next)

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 17 Advice for Subject.attach Pointcut declaration this calls target.method(args) Preconditions (before advice in AspectJ) code block executed after the postconditions are checked. The beginning of advice definition The end of advice definition

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 18 Modularizing assertion in aspect Aspect adds an additional field to Observer and assertions using the field to Subject. Inter-type declaration advice

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 19 Effect on software quality Assertion and Design by Contract Assertion crosscutting objects Example: Observer pattern with an inter-object constraint Aspect for Assertion Rewriting inter-object constraint using aspect Discussions Effect on software quality Related work

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 20 Improved modularity (1/2) Related assertions, fields and methods groups together. In observer example, the subject field is separated from classes. An aspect prevents developers from misusing such fields and methods for other purposes.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 21 Improved modularity (2/2) Context-specific assertions can be defined in each aspect. An example: additional assertion checked when a component is called from an experimental code. The assertion is not checked when the component is called from a well-tested component. A developer can explicitly separate additional assertions. A component Well-tested Component Experimental Code Strict checking aspect

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 22 Improved reusability A developer can easily add and remove specific purpose assertion, e.g. for testing and debugging. A developer can reuse assertion modules for debugging developed in the past debugging task. application-specific constraints for a generic component. Observer pattern implementation is usable for many-to- many relationship when a developer remove one-to- many constraint aspect.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 23 Drawback: reduced readability Multiple aspects define assertions for a component. Q. Does a developer have to inspect all aspects to understand a component ? If a developer want to know all possible behavior of the component, yes, he or she has to inspect all aspects. When a developer inspects a pair of a component and its client, the developer has to inspect assertions only for the pair. Tool-support for developers to manage and inspect aspects is important. For the safety, we set a limit to aspect: an aspect can add assertions, but cannot remove. Even if a developer has no information about aspects, testing reveals violated assertions added by aspects.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 24 Related work Behavioral Specification Language JML, Larch, … Useful and practical in OOP Our proposal is an AOP extension for them. Other extensions for behavioral specification Temporal Invariants (Gibbs et al.) It introduces temporal logic to describe assertion. It can specify assertions for a sequence of method calls. Pipa (Zhao et al.) JML extension for advices in AspectJ. Moxa (Yamada et al.) JML extension for common contract to a set of methods.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 25 Summary and future work Assertion is a useful tool for software development. However, some assertion crosscuts objects. We propose aspect-oriented modularization of assertion. AOP improves modularity of assertion, reusability of assertion and reusability of components. Future work Evaluating how features contribute expressive and powerful assertion. control and data flow pointcut annotation-based pointcut temporal logic state-based join point model Detecting and modularizing a common constraint among modules. To support program understanding.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 26

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 27 Behavioral Subtyping A component with additional assertion is out of the behavioral subtype. require (pre- condition) ensure (postcondition) Strong Weak Strong Weak Behavioral Subtyping Specialized Implementation Original Component Simple Implementation Generalization Extension Assertion Aspect

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 28 Moxa’s approach Instead of listing assertions for each method, lisitng methods for each assertion. Method 1 Method 2 Method 3 Assert A Assert B Assert C Assert A Assert B Assert A Assert C Assert B Method 1 Method 2 Method 3 JMLMoxa

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 29 Implementation of Translator Using Racc, Parser Generator for Ruby. Simple rules are defined. PreX; { Block 1 } PostY; { Block 2 } Z; before(): pointcut { assert(X); Block 1; } after(): pointcut { assert(Y); Block 2; assert(Z); }

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 30 Implementation of Translator (2) Pointcut translation A calls B.signature(C) call(* ClassOfB.signature(..)) && this(A) && target(B) && args(C)