Software Development CSU 670 Karl Lieberherr

Slides:



Advertisements
Similar presentations
Controlling the Complexity of Software Designs Karl Lieberherr College of Computer and Information Science Northeastern University.
Advertisements

February R. McFadyen1 Polymorphism Indirection Pure Fabrication Protected Variations (Law of Demeter) More GRASP Patterns.
March R. McFadyen1 Principle of Least Knowledge – page 265 Principle: talk only to your immediate friends Also called Law of Demeter (LoD)
Oct 21, R. McFadyen1 Pure Fabrication P Problem: You have a responsibility to assign to a class, but assigning it to a class in the conceptual.
March R. McFadyen1 Pure Fabrication P Problem: You have a responsibility to assign to a class, but assigning it to a class in the conceptual.
3/7/2003Bioinformatics1 How To Address Rapidly Changing Data Representations in an Evolving Scientific Domain Using Aspect-oriented Programming Techniques.
Controlling the Complexity of Software Designs Karl Lieberherr College of Computer and Information Science Northeastern University.
Demeter and Aspects1 AOSD 2002 Tutorial: Demeter Aspect-Oriented Programming of Traversal Related Concerns in Java Demeter Research Group.
Pattern Language for AP1 Pattern Language for Adaptive Programming (AP) Karl Lieberherr Northeastern University.
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.
Take-Home Final COM 3205 Fall Stamp Coupling Def: data structure is passed as parameter, but called method operates on only some of the` individual.
Aspect Oriented Programming Gülşah KARADUMAN.
3/7/2003 ABB rapid change 1 How To Address Rapidly Changing Data Representations in an Evolving Scientific Domain Using Aspect-oriented Programming Techniques.
Slides for Gregor Kiczales Two versions –short version: Crosscutting capabilities for Java and AspectJ through DJ (4 viewgraphs only) –long version: Controlling.
Not only mark-up languages! There are other many other grammar formalisms and tools than XML. Some of them standardized (ASN). Even XML does not always.
Catalysis/Testing Catalysis Objects, components, and Frameworks with UML.
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.
Pattern Language for AP1 Pattern Language for Adaptive Programming (AP) Karl Lieberherr Northeastern University.
CSG 7111 Structure and Interpretation of an Aspect Language for Datatype Karl Lieberherr.
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.
Demeter Aspects We study techniques for the emerging area of Aspect-Oriented Software Development and focus on the following areas:  Aspectual Collaborations.
Controlling the Complexity of Software Designs Karl Lieberherr College of Computer and Information Science Northeastern University.
XAspects slides Cross-cutting of concerns ordinary program structure-shy functionality structure synchronization better program Chapter 1 Chapter 2 Chapter.
Problem with Java and how it causes a problem for DJ.
AOP/cross-cutting What is an aspect?. An aspect is a modular unit that cross-cuts other modular units. What means cross-cutting? Apply AOP to AOP. Tease.
Why Should You Care About Aspect-Oriented Programming? Karl Lieberherr CCIS.
Pattern Language for AP1 Pattern Language for Adaptive Programming (AP) Karl Lieberherr Northeastern University.
Talk only to your friends that share the same concerns (Law of Demeter for Concerns) Midterm Review February 2004.
Pattern Language for AP1 Pattern Language for Adaptive Programming (AP) Karl Lieberherr Northeastern University.
Crosscutting Capabilities for Java and AspectJ through DJ
Pattern Language for Adaptive Programming (AP)
Structure and Interpretation of an Aspect Language for Datatype
Controlling the Complexity of Software Designs
Demeter Aspects Who We Are Aspectual Collaborations
Inheritance "Question: What is the object oriented way of getting rich? Answer: Inheritance.“ “Inheritance is new code that reuses old code. Polymorphism.
Adaptive Object-Oriented Software Development
Smaller, More Evolvable Software
Software Design and Development
Controlling the Complexity of Software Designs
ADAPTIVE PROGRAMMING Sezen ERDEM December 2005.
Northeastern University, CCIS/PRL
Software Design and Development
Karl Lieberherr CCIS/PRL Northeastern University
Third lecture Review Visitor pattern DemeterJ 12/25/2018 SD.
Building Modular Object-Oriented Systems with Reusable Collaborations
Midterm Review CSU 670 Spring 2004.
AP/DJ AP: a generic technology
Adaptive and Aspect-Oriented Object-Oriented Software Development
Karl J. Lieberherr Northeastern University College of Computer Science
Sustainable Software Karl Lieberherr Northeastern University
Lecture 21: Crosscutting Aspect-Oriented Programming Background
Adaptive Plug and Play Components for
Better Separation of Crosscutting Concerns with Aspectual Components
Third lecture Review Visitor pattern DemeterJ 2/17/2019 SD.
AOSD and the Law of Demeter: Shyness in Programming
Nested Collaborations
Declarative Techniques for Improving Aspect Orthogonality
Aspects at the Design Level
Objects, components, and Frameworks with UML
College of Computer Science
Overview Structure-shy Object pattern
Aspect Oriented Software Design
Karl Lieberherr Doug Orleans
Coordination aspect Review of AOP Summary of threads in Java
Presentation transcript:

CSU 670 Karl Lieberherr https://lists.ccs.neu.edu/bin/listinfo/ Software Development CSU 670 Karl Lieberherr https://lists.ccs.neu.edu/bin/listinfo/ First lecture, first class Sep25. 4/10/2019 CSU 670/1

Cross-cutting of concerns better program ordinary program structure-shy functionality Chapter 1 structure Chapter 2 avoid tangled programs AOP synchronization Chapter 3 Woven meaning of book 4/10/2019 CSU 670/1

crosscutting concerns 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(); 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;} width_ = longCalculation3(); height_ = longCalculation4(); 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 ; Modularization of crosscutting concerns public class Shape { protected double x_= 0.0, y_= 0.0; protected double width_=0.0, height_=0.0; double get_x() { return x_(); } void set_x(int x) { x_ = x; } double get_y() { return y_(); } void set_y(int y) { y_ = y; } double get_width(){ return width_(); } void set_width(int w) { width_ = w; } double get_height(){ return height_(); } void set_height(int h) { height_ = h; } void adjustLocation() { x_ = longCalculation1(); y_ = longCalculation2(); } void adjustDimensions() { width_ = longCalculation3(); height_ = longCalculation4(); coordinator Shape { selfex adjustLocation, adjustDimensions; mutex {adjustLocation, get_x, set_x, get_y, set_y}; mutex {adjustDimensions, get_width, get_height, set_width, set_height}; portal Shape { double get_x() {} ; void set_x(int x) {}; double get_y() {}; void set_y(int y) {}; double get_width() {}; void set_width(int w) {}; double get_height() {}; void set_height(int h) {}; void adjustLocation() {}; void adjustDimensions() {}; Write this Instead of writing this 4/10/2019 CSU 670/1

UML Class Diagram busStops BusRoute BusStopList buses 0..* BusStop BusList Example for developing strategies and writing adaptive programs waiting 0..* passengers Bus PersonList Person 0..* 4/10/2019 CSU 670/1

Collaborating Classes use connectivity in class graph to define them succinctly using strategy graphs separating structure from behavior teasing out the structure aspect from Customer to Agent from Company to Employee 4/10/2019 CSU 670/1

What's the problem? TANGLING OOAD Z customer service center teller service self-service collaborations Collab-1 requirements: use-cases C1 C4 C2 C3 C5 Collab-4 Collab-2 Collab-3 Object-oriented languages do not provide adequate constructs to capture collaborations between several classes. Has been recognized in different forms in the object-oriented community: OO accommodates the addition of new variants of data types better than procedural programming but, the opposite is true when new operations on existing data types are needed visitor pattern: the matter of concern -- definition of new operations on an existing object structure (aggregation is involved besides inheritance) several works complain the lack of constructs for expressing collaboration-based designs C1 C4 C2 C3 Implementation C5 classes Collaboration -- a distinct (relatively independent aspect of an application that involves several participants, or roles roles played by application classes each class may play different roles in different collaborations each role embodies a separate aspect of the overall class behavior 4/10/2019 CSU 670/1 Collaboration-based design s Require to view oo applications in two different ways: (a) in terms of participants or types involved (b) in terms of the tasks or concerns of the design

Problems with Object Decomposition in den vorherigen Kapiteln wurde erklärt: 1. in der Informatik darum, Rechnermodelle zu bauen, die Prozessen in der reellen Welt simulieren. 2. Es gibt formale Mitteln, die es erlauben, die Modelle in eine für den Rechner verständlich en Sprache zu schreiben.t. In dieser Vorlesung erden wir das sogenannte objekt-orientierte Programmiermodel als das Mittel für die Beschreibung der Modelle benutzen. Mit anderen Worten, werden wir objekt-orientierte Rechnermodelle der reellen Welt bauen. Wir werden zuerst, die Konstrukte des objekt-orientierten Programmiermodels kennenlernen, d.h. die Bestandteile unsere Toolboxes. Als zweites werden wir kurz During implementation separate higher-level functions are mixed together During maintenance/evolution individual collaborations need to be factored out of the tangled code

Collaborating Classes find all persons waiting at any bus stop on a bus route busStops BusRoute BusStopList OO solution: one method for each red class buses 0..* BusStop BusList waiting 0..* passengers Bus PersonList Person 0..* 4/10/2019 CSU 670/1

TPP section: Decoupling and the Law of Demeter Write shy code: A shy person does not interact with too many people. A shy method does not interact with too many classes/objects. 4/10/2019 CSU 670/1

find all persons waiting at any bus stop on a bus route Traversal Strategy first try: from BusRoute to Person busStops BusRoute BusStopList buses 0..* BusStop BusList waiting 0..* passengers Bus PersonList Person 0..* 4/10/2019 CSU 670/1

find all persons waiting at any bus stop on a bus route Traversal Strategy from BusRoute through BusStop to Person busStops BusRoute BusStopList buses 0..* BusStop BusList waiting 0..* passengers Bus PersonList Person 0..* 4/10/2019 CSU 670/1

find all persons waiting at any bus stop on a bus route Traversal Strategy Altern.: from BusRoute bypassing Bus to Person busStops BusRoute BusStopList buses 0..* BusStop BusList waiting 0..* passengers Bus PersonList Person 0..* 4/10/2019 CSU 670/1

Robustness of Strategy find all persons waiting at any bus stop on a bus route Robustness of Strategy from BusRoute through BusStop to Person villages BusRoute BusStopList busses VillageList busStops 0..* 0..* BusStop BusList Village waiting 0..* passengers Bus PersonList Person 0..* 4/10/2019 CSU 670/1

TPP: Tip 53: Abstractions Live Longer than Details Is in the Requirements Pit section Also applies to code: don’t overspecify! 4/10/2019 CSU 670/1

Writing Adaptive Programs with Strategies (DJ=pure Java) String WPS=“from BusRoute through BusStop to Person” class BusRoute { int countPersons(ClassGraph cg) { String WPS=“from BusRoute through BusStop to Person” Integer result = (Integer) cg.traverse(this, WPS, new Visitor(){ int r ; public void before(Person host){ r++; } public void start() { r = 0;} public Object getReturnValue() {return new Integer ( r);} }); return result.intValue();} } can we really program with strategies? Here is how. 4/10/2019 CSU 670/1

Writing Adaptive Programs with Strategies (DJ=pure Java) // Prepare the class graph ClassGraph classGraph = new ClassGraph(); int r = aBusRoute.countPersons(classGraph); can we really program with strategies? Here is how. 4/10/2019 CSU 670/1

TPP section: The Evils of Duplication Tip 11: DRY – Don’t Repeat Yourself Imposed duplication without tool support 4/10/2019 CSU 670/1

Cross-cutting in DemeterJ generated Java program DemeterJ program structure-shy functionality structure replicated! aspect descriptions are not just copied into programs, they may be replicated several times. synchronization 4/10/2019 CSU 670/1

Back to COM 1350 A context-free grammar is a 4-tuple (V,Sigma,R,S) V : Variables (or non terminals) Sigma: terminals R : rules S : start variable 4/10/2019 CSU 670/1