Take-Home Final COM 3205 Fall 2002. Stamp Coupling Def: data structure is passed as parameter, but called method operates on only some of the` individual.

Slides:



Advertisements
Similar presentations
INTERFACES IN JAVA 1.Java Does not support Multiple Inheritance directly. Multiple inheritance can be achieved in java by the use of interfaces. 2.We need.
Advertisements

Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
1 Shyness in Programming Karl Lieberherr Demeter Research Group Northeastern University Boston.
Controlling the Complexity of Software Designs Karl Lieberherr College of Computer and Information Science Northeastern University.
Exercises on Basic OOP TCP1201: 2013/2014. Catch the Bug 1 class Point { private : int x, y; public : Point(int u, int v) : x(u), y(v) { } int getX()
Denotational Semantics Syntax-directed approach, generalization of attribute grammars: –Define context-free abstract syntax –Specify syntactic categories.
Chapter 10: Inheritance and Polymorphism
Chapter 11: Inheritance and Polymorphism Java Programming: Program Design Including Data Structures Program Design Including Data Structures.
Introduction to Aspect- Oriented Programming CS 3360 Gregor Kiczales, et. al. Getting started with AspectJ, CACM, 44(10):59-65, October Fall 2012.
1 Data Structures - CSCI 102 CS102 C++ Polymorphism Prof Tejada.
Controlling the Complexity of Software Designs Karl Lieberherr College of Computer and Information Science Northeastern University.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Week 3 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Extensible Plug-ins for Aspect-Oriented Programming Macneil Shonle*Ankit Shah.
Object-Oriented Analysis and Design An Introduction.
Expression evaluation E : S | C. S = int. C = Op E E. Op : A | M. A = “+”. M = “*”.
Controlling the Complexity of Software Designs Karl Lieberherr College of Computer and Information Science Northeastern University.
Problems with Send and Receive Low level –programmer is engaged in I/O –server often not modular –takes 2 calls to get what you want (send, followed by.
Slides for Gregor Kiczales Two versions –short version: Crosscutting capabilities for Java and AspectJ through DJ (4 viewgraphs only) –long version: Controlling.
Chris Kiekintveld CS 2401 (Fall 2010) Elementary Data Structures and Algorithms Inheritance and Polymorphism.
Cohesion and Coupling CS 4311
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
AOSD1 Aspect-Oriented Software Design Karl Lieberherr Theo Skotiniotis.
System Body Thing * * Definition Fig. UML1 def body Ident S D T B definitions things.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 Reducing synchronization.
The following viewgraphs about RIDL from: D: A Framework for Distributed Programming Cristina Videira Lopes.
Cross cutting Cross-cutting of components and aspects ordinary program structure-shy functionality structure synchronization better program Components.
Aspect-Oriented Programming and Modular Reasoning G. KiczalesM. Mezini Presented by Alex Berendeyev.
AOP Foundations Doug Orleans Karl Lieberherr. What we did earlier AOP languages have the following main elements: –a join point model (JPM) wrt base PL.
System Body Thing * * Definition Fig. UML1 def body Ident S D T B definitions things.
IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.
1 XAspects An Extensible System for Domain- Specific Aspect Languages Macneil Shonle (UCSD) Karl Lieberherr (Northeastern University) Ankit Shah (Northeastern.
1 Modularization of crosscutting concerns Write this public class Shape { protected double x_= 0.0, y_= 0.0; protected double width_=0.0, height_=0.0;
Controlling the Complexity of Software Designs Karl Lieberherr College of Computer and Information Science Northeastern University.
Controlling the Complexity of Software Designs Karl Lieberherr College of Computer and Information Science Northeastern University.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Salman Marvasti Sharif University of Technology Winter 2015.
Controlling the Complexity of Software Designs Karl Lieberherr College of Computer and Information Science Northeastern University.
Inheritance CSI 1101 Nour El Kadri. OOP  We have seen that object-oriented programming (OOP) helps organizing and maintaining large software systems.
Java Programming: From Problem Analysis to Program Design, 3e Chapter 11 Inheritance and Polymorphism.
DJ: traversal-visitor-style programming in Java Josh Marshall/ Doug Orleans Want to add more on traversal through collections and Aspectual Components.
Topic 8Classes, Objects and Methods 1 Topic 8 l Class and Method Definitions l Information Hiding and Encapsulation l Objects and Reference Classes, Objects,
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 Confinement.
XAspects slides Cross-cutting of concerns ordinary program structure-shy functionality structure synchronization better program Chapter 1 Chapter 2 Chapter.
Introduction to Aspect- Oriented Programming CS 3360 Gregor Kiczales, et. al. Getting started with AspectJ, CACM, 44(10):59-65, October Spring 2012.
Copyright 1997, 1998 Xerox Corporation - Dijkstra, A discipline of programming, 1976 last chapter, In retrospect “To my taste the main characteristic of.
Why Should You Care About Aspect-Oriented Programming? Karl Lieberherr CCIS.
Powerpoint slides from A+ Computer Science Modified by Mr. Smith for his course.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Crosscutting Capabilities for Java and AspectJ through DJ
Inheritance ITI1121 Nour El Kadri.
Chapter 11: Inheritance and Polymorphism
Chapter 3: Using Methods, Classes, and Objects
Controlling the Complexity of Software Designs
For John.
Controlling the Complexity of Software Designs
Northeastern University, CCIS/PRL
Software Design and Development
Karl Lieberherr CCIS/PRL Northeastern University
Sustainable Software Karl Lieberherr Northeastern University
OO Design with Inheritance
Better Separation of Crosscutting Concerns with Aspectual Components
AOSD and the Law of Demeter: Shyness in Programming
Module 2 - Part 1 Variables, Assignment, and Data Types
Software Development CSU 670 Karl Lieberherr
Declarative Techniques for Improving Aspect Orthogonality
College of Computer Science
Overview Structure-shy Object pattern
Java Remote Method Invocation
Introduction to Computer Science and Object-Oriented Programming
Presentation transcript:

Take-Home Final COM 3205 Fall 2002

Stamp Coupling Def: data structure is passed as parameter, but called method operates on only some of the` individual components of the structure. Example: calculate withholding (pass entire employee record although only a slice is needed) Why is this bad? affects understanding; not clear, without reading entire module, which fields of record are accessed or changed; unlikely to be reusable other products have to use the same higher level data structures; passes more data than necessary e.g., uncontrolled data access can lead to computer crime.

Dynamic Stamp Coupling (DSC) For one execution. Like LoD checker (class form). Given a method call a.f(b), if "not all of b is used" in the control flow of the call, DSC is violated for this call. So DSC is a call join point predicate.

DSC "not all of b is used" can be interpreted in various ways: –b is never used. –b has subparts some of which are never used. "used" can be interpreted in various ways: –sent a message, assigned to a variable, passed as a parameter, read, written. Chose the interpretation you find most appropriate and give an explanation for your choice.

Discussion of DSC Consider an equation system Want to check an equation system. Are all used variables defined? We don’t have to look at all objects: Add, Numercial objects don’t have to be touched. Violation of DSC?

Class graph: Find undefined things System Body Thing * * * definedThings usedThings definedThings= from System bypassing Body to Thing usedThings = from System through Body to Thing * Definition Fig. UML1 def body Ident S D T B

M1: Equation System EquationSystem Equation_List Equation Variable equations * lhs rhs Expression Simple Compound Numerical Expression_List * Add op args Fig. Eq1 Ident

Equation System Object equations lhs rhs Fig. Eq4 es:EquationSystem els:Equation_List e1:Equationv1:Variable i1:Ident v2:Variable i2:Ident

M1: Equation System definedThings = from EquationSystem bypassing Expression to Variable EquationSystem Equation_List Equation Variable equations * lhs rhs Expression Simple Compound Numerical Expression_List * Add op args Fig. Eq2 Ident S D T B

M1: Equation System usedThings = from EquationSystem through Expression to Variable EquationSystem Equation_List Equation Variable equations * lhs rhs Expression Simple Compound Numerical Expression_List * Add op args Fig. Eq3 Ident S D T B

A Java program that checks Does not touch all objects. Not a violation of dynamic stamp coupling?

Java Program: Adaptive Method with DJ class System{ String id = “from Thing to edu.neu.ccs.demeter.Ident”; void repUndef(ClassGraph cg){ checkDefined(cg, getDefThings(cg));} HashSet getDefThings(ClassGraph cg){ String definedThings = "from System bypassing Body to Thing"; Visitor v = new Visitor(){ HashSet return_val = new HashSet(); void before(Thing v1){ return_val.add(cg.fetch(v1, id) );} public Object getReturnValue(){return return_val;}}; cg.traverse(this, definedThings, v); return (HashSet)v.getReturnValue(); } green: traversal black bold: structure purple: advice red: parameters repUndef is a modular unit of crosscutting implementation. Ad-hoc implementation may cut across 100 classes.

void checkDefined(ClassGraph cg, final HashSet classHash){ String usedThings = ”from System through Body to Thing"; cg.traverse(this, usedThings, new Visitor(){ void before(Thing v){ Ident vn = cg.fetch(v, vi); if (!classHash.contains(vn)){ System.out.println("The object "+ vn + " is undefined."); }}});} } Java Program: Adaptive Method with DJ

RIDL provides means for dealing with data transfers between different execution spaces opop Execution space 1 otot Execution space 2 o t.m(o p ) ? Portals

public class Shape implements ShapeI { protected AdjustableLocation loc; protected AdjustableDimension dim; public Shape() { loc = new AdjustableLocation(0, 0); dim = new AdjustableDimension(0, 0); } double get_x() throws RemoteException { return loc.x(); } void set_x(int x) throws RemoteException { loc.set_x(); } double get_y() throws RemoteException { return loc.y(); } void set_y(int y) throws RemoteException { loc.set_y(); } double get_width() throws RemoteException { return dim.width(); } void set_width(int w) throws RemoteException { dim.set_w(); } double get_height() throws RemoteException { return dim.height(); } void set_height(int h) throws RemoteException { dim.set_h(); } void adjustLocation() throws RemoteException { loc.adjust(); } void adjustDimensions() throws RemoteException { dim.adjust(); } interface ShapeI extends Remote { double get_x() throws RemoteException ; void set_x(int x) throws RemoteException ; double get_y() throws RemoteException ; void set_y(int y) throws RemoteException ; double get_width() throws RemoteException ; void set_width(int w) throws RemoteException ; double get_height() throws RemoteException ; void set_height(int h) throws RemoteException ; void adjustLocation() throws RemoteException ; void adjustDimensions() throws RemoteException ; } class AdjustableLocation { protected double x_, y_; public AdjustableLocation(double x, double y) { x_ = x; y_ = y; } synchronized double get_x() { return x_; } synchronized void set_x(int x) {x_ = x;} synchronized double get_y() { return y_; } synchronized void set_y(int y) {y_ = y;} synchronized void adjust() { x_ = longCalculation1(); y_ = longCalculation2(); } class AdjustableDimension { protected double width_=0.0, height_=0.0; public AdjustableDimension(double h, double w) { height_ = h; width_ = w; } synchronized double get_width() { return width_; } synchronized void set_w(int w) {width_ = w;} synchronized double get_height() { return height_; } synchronized void set_h(int h) {height_ = h;} synchronized void adjust() { width_ = longCalculation3(); height_ = longCalculation4(); } thread synchronization remote interaction

RIDL Identifies “good” abstractions for controlling remote interactions of OO programs –remote method calls –different parameter passing semantics –selective object copying –... Sources: Study of many distributed programs

RIDL Book Locator / Printer class Book { protected String title, author; protected int isbn; protected OCRImage firstpage; protected Postscript ps; } class BookLocator { private Book books[]; private Location locations[]; public void register(Book b, Location l){ // Verify and add book b to database } public Location locate (String title) { Location loc; // Locate book and get its location return loc; } class Printer { public void print(Book b) { // Print the book } coordinator BookLocator { selfex register; mutex {register, locate}; } portal BookLocator { void register (Book book, Location l); Location locate (String title) default: Book: copy{Book only title, author, isbn;} } portal Printer { void print(Book book) { book: copy { Book only title, ps; } } class Location { private String building; }

Selective Marshaling portal Printer { void print(Book book) { book: copy { Book only title, ps; } } class Book { protected String title, author; protected int isbn; protected OCRImage firstpage; protected Postscript ps; }

Selective Marshaling portal Library { BookCopy getBook(User u, String title) { return: copy {BookCopy bypass borrower, Book bypass copies;} u: copy {User bypass books;} } Book findBook(String title) { return: copy {Book bypass copies, ps;} } Library UserBook BookCopy booksusers theBook borrower ** * * copies books

Programming with RIDL object portal m(){ …} Protocol object/portal: 1 1: remote method invocation 2: request presented to the portal 2 3 3: parameters extracted according to transfer specifications 4: request proceeds to the object 4 5 5: method execution 6: return is presented to portal 6 7 7: return value processed according to transfer specification 8 8: method returns; return value sent