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.

Slides:



Advertisements
Similar presentations
February R. McFadyen1 Polymorphism Indirection Pure Fabrication Protected Variations (Law of Demeter) More GRASP Patterns.
Advertisements

Oct R McFadyen1 Recall UML Class Diagram BusRoute BusStopList BusStop BusList BusPersonList Person passengers buses busStops waiting 0..*
INTERPRETER Main Topics What is an Interpreter. Why should we learn about them.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Defining practical programming languages Carlos Varela RPI.
Detailed Design Kenneth M. Anderson Lecture 21
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
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.
Satzinger, Jackson, and Burd Object-Orieneted Analysis & Design
SMIILE Finaly COBOL! and what else is new Gordana Rakić, Zoran Budimac.
Marcelo Santos – OOAD-CDT309, Spring 2008, IDE-MdH 1 Object-Oriented Analysis and Design - CDT309 Period 4, Spring 2008 Design Patterns: someone has already.
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.
UML class diagrams and XML schemas Karl Lieberherr UBS AG Northeastern University.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Design Patterns Discussion of pages: xi-11 Sections: Preface, Forward, Chapter
Chapter 2 Syntax A language that is simple to parse for the compiler is also simple to parse for the human programmer. N. Wirth.
3/7/2003Bioinformatics1 How To Address Rapidly Changing Data Representations in an Evolving Scientific Domain Using Aspect-oriented Programming Techniques.
 Copyright 2005 Digital Enterprise Research Institute. All rights reserved. Towards Translating between XML and WSML based on mappings between.
Gr ? Can use symbolic notation – not assess learn.. Use concrete material counted by ones Zero? numeral, digit,
Catalysis/Testing Catalysis Objects, components, and Frameworks with UML.
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
1 WXGC6102: Object-Oriented Techniques Modelling Concepts References: Chapter 5 of Bennett, McRobb and Farmer: Object Oriented Systems Analysis and Design.
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 = “*”.
Copyright 2002 Prentice-Hall, Inc. Chapter 2 Object-Oriented Analysis and Design Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey.
Slides for Gregor Kiczales Two versions –short version: Crosscutting capabilities for Java and AspectJ through DJ (4 viewgraphs only) –long version: Controlling.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Law of Demeter. What is it: Style Rule for building systems. Proposed by my research group: The Demeter Research Group in 1987, published in Covered.
Chapter 16 Applying UML and Patterns Craig Larman
Catalysis/Testing Catalysis Objects, components, and Frameworks with UML.
Sheet 1 DocEng’03, Grenoble, November 2003 Model Driven Architecture based XML Processing Ivan Kurtev, Klaas van den Berg University of Twente, the Netherlands.
Towards the better software metrics tool motivation and the first experiences Gordana Rakić Zoran Budimac.
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.
Adaptive Software Kevin Cella Graduate Seminar 02/04/2005.
Object-Oriented Modeling: Static Models. Object-Oriented Modeling Model the system as interacting objects Model the system as interacting objects Match.
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
The Interpreter Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
DJ: traversal-visitor-style programming in Java Josh Marshall/ Doug Orleans Want to add more on traversal through collections and Aspectual Components.
The Hashemite University Computer Engineering Department
Concepts and Realization of a Diagram Editor Generator Based on Hypergraph Transformation Author: Mark Minas Presenter: Song Gu.
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.
Pattern Language for AP1 Pattern Language for Adaptive Programming (AP) Karl Lieberherr Northeastern University.
R-customizers Goal: define relation between graph and its customizers, study domains of adaptive programs, merging of interface class graphs.
UBC software modularity group 1/14/02 UCSD1 Discussion with Kiczales at UBC Ontology of AOP Ontology is the study of what there is, an inventory of what.
AO Mechanisms in Demeter1 Discussion with Gregor Kiczales at UBC Ontology of AOP Ontology is the study of what there is, an inventory of what exists. An.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
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.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Crosscutting Capabilities for Java and AspectJ through DJ
Pattern Language for Adaptive Programming (AP)
Structure and Interpretation of an Aspect Language for Datatype
Discussion with Gregor Kiczales at UBC
Adaptive Object-Oriented Software Development
Presentation by Julie Betlach 7/02/2009
Software Design and Development
ADAPTIVE PROGRAMMING Sezen ERDEM December 2005.
Midterm Review CSU 670 Spring 2004.
AP/DJ AP: a generic technology
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Lecture 21: Crosscutting Aspect-Oriented Programming Background
Computer Science and Engineering
Computer Science and Engineering
Objects, components, and Frameworks with UML
Presentation transcript:

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 use its own formalism: XPATH, the navigation language of XML uses a syntax that is more concise than markup syntax. Structure-shy Object Pattern

Pattern Language for AP2 Structure-shy Object Intent –Make object descriptions for tree objects robust to changes of class structure. –Make object descriptions for tree objects independent of class names.

Pattern Language for AP3 Structure-shy Object Could also be called: –Object Parsing –Grammar –Abstract=Concrete Syntax

Pattern Language for AP4 Structure-shy Object Motivation –Data maintenance a major problem when class structure changes –Tedious updating of constructor calls –The creational patterns in the design pattern book also recognize need –Concrete syntax is more abstract than abstract syntax!

Pattern Language for AP5 Structure-shy Object Applicability –Useful in object-oriented designs of any kind. –Especially useful for reading and printing objects in user-friendly notations. Ideal if you control notation. –If you see many constructor calls: think of Structure-shy Object.

Pattern Language for AP6 Structure-shy Object Solution –Extend the class structure definitions to define the syntax of objects. –Each class will define a parse function for reading objects and a print visitor for printing all or parts of an object.

Pattern Language for AP7 Structure-shy Object Solution –Start with familiar grammar formalism and change it to make it also a class definition formalism. In the Demeter group we use Wirth’s EBNF formalism. –Use a parser generator (like YACC or JavaCC) or a generic parser.

Pattern Language for AP8 Parsers weave sentences into objects Problem in OO programs: Constructor calls for compound objects are brittle with respect to structure changes. Solution: Replace constructor calls by calls to a parser. Annotate class diagram to make it a grammar. Benefit: reduce size of code to define objects, object descriptions are more robust Correspondence: Sentence defines a family of objects. Adaptive program defines family of object-oriented programs. In both cases, family member is selected by (annotated) class diagram. Structure-shy Object

Pattern Language for AP9 Run-time weaving: Description Sentence * Grammar Compound... Simple... Number... Multiply... Add... etc. C M * N 3 C A + NN 45 Object in linear form (Constructor calls) C M * N 3 C A + N 4 N 5 Object as tree Grammar defined by annotating UML class diagram SENTENCE IS MORE ROBUST THAN OBJECT Structure-shy Object

Pattern Language for AP10 Structure-shy Object Consequences –more robust and shorter object descriptions –Need to deal with unique readability with respect to an efficient parsing algorithm –Can guarantee unique readability by adding more syntax –debug class structures by reading objects

Pattern Language for AP11 Structure-shy Object Related patterns –Creational patterns in design pattern book. –Interpreter pattern uses similar idea but fails to propose it for general object-oriented design. –Structure-shy Object useful in conjunction with Prototype pattern.

Pattern Language for AP12 Structure-shy Object Known uses –Demeter Tools since 1986, T-gen, applications of YACC, programming language Beta and many more.

Pattern Language for AP13 Structure-shy Object References –Chapters 11 and 16 of AP book describe details. Exercise –Use your favorite grammar notation and modify it to also make it a class graph notation.

Navigation What can XML users learn from OO designers? Navigation through documents should be structure-shy: Structure-shy object pattern

Pattern Language for AP15 Structure-shy Traversal Intent –Succinctly represent a traversal to be performed on objects –Commit only to navigation strategy and specify navigation details later

Pattern Language for AP16 Structure-shy Traversal Could also be called: –Adaptive Traversal –Structure-shy Walker

Pattern Language for AP17 Structure-shy Traversal Motivation –Noise in objects for specific task –Focus on long-term intent –Don’t want to attach every method to a specific class explicitly. Leads to brittle programs. –Small methods problem (example: 80% of methods are two lines long or shorter)

Pattern Language for AP18 Structure-shy Traversal Applicability –Need collaboration of at least two classes. –In the extreme case, each data member access is done through a succinct traversal specification. –Some subgraphs don’t have a succinct representation, for example a path in a complete graph. More generally: avoid well connected, dense graphs.

Pattern Language for AP19 Structure-shy Traversal Solution –Use succinct subgraph specifications –Use succinct path set specifications

Pattern Language for AP20 Structure-shy Traversal: Solution Traversal Strategy Graphs (Strategies) –First stage: A strategy is a graph with nodes and edges. Nodes are labeled with nodes of a class graph. Edges mean: all paths. –Second stage: label edges with constraints excluding edges and nodes in class graph –Third stage: Encapsulated strategies. Use symbolic elements and map to class graph.

Pattern Language for AP21 Structure-shy Traversal: Solution Traversal Strategy Graphs (Strategies) –Simplest useful strategy: One Edge. Possible syntax: from Company to Salary or {Company -> Salary} –Line graph. Several edges in a line. Possible syntax: From Company via Employee to Salary {Company -> Employee, Employee -> Salary}

Pattern Language for AP22 Structure-shy Traversal: Solution Traversal Strategy Graphs (Strategies) –Star graph From Company to {Personnel, Travel, Employee} Company TravelPersonnel Employee

Pattern Language for AP23 UML Class Diagram BusRoute BusStopList BusStop BusList BusPersonList Person passengers buses busStops waiting 0..*

Pattern Language for AP24 Traversal Strategy BusRoute BusStopList BusStop BusList BusPersonList Person passengers buses busStops waiting 0..* from BusRoute through BusStop to Person find all persons waiting at any bus stop on a bus route

Pattern Language for AP25 Robustness of Strategy BusRoute BusStopList BusStop BusList BusPersonList Person passengers buses busStops waiting 0..* from BusRoute through BusStop to Person VillageList Village villages 0..* find all persons waiting at any bus stop on a bus route

Pattern Language for AP26 Structure-shy Traversal Consequences –Programs become shorter and more powerful. A paradox. With less work we achieve more. Polya’s inventor paradox. –Program will adapt to many changes in class structure.

Pattern Language for AP27 Structure-shy Traversal Implementation –Many different models for succinct traversal specifications. –Best one: Strategies –Correct implementation of strategies is tricky. See paper by Lieberherr/Patt-Shamir strategies.ps in my FTP directory.

Pattern Language for AP28 Structure-shy Traversal Known Uses –XPATH of XML –Adaptive Programming: Demeter/C++, Demeter/Java, Dem/Perl, Dem/CLOS etc. –Databases (limited use): Structure-shy queries: See Cole Harrison’s Master’s Thesis (Demeter Home Page) –Artificial Intelligence (limited use): Minimal ontological commitment