Midterm Winter 2002 Karl Lieberherr.

Slides:



Advertisements
Similar presentations
Fundamentals of Software Development 1Slide 1 Programming Patterns: Motivation Many problems fit a “pattern” that experienced software developers recognizeMany.
Advertisements

Software Development CSU 670 Fall 2007 Karl Lieberherr.
OOPDA Review. Terminology class-A template defining state and behavior class-A template defining state and behavior object-An instance of a class object-An.
x + 5 = 20 x+5 20 (-5) x + 5 = 20 x 20 (-5) x + 5 = 20.
Hello AP Computer Science!. What are some of the things that you have used computers for?
Laboratory Study October, The very first example, traditional "Hello World!" program: public class first { public static void main (String[ ]
CompSci 42.1Intro to Java Anatomy of a Class & Terminology Running and Modifying a Program.
Integrating Independent Components with On-Demand Remodularization based on OOPSLA 2002 paper by Mira Mezini Klaus Ostermann Prepared by Karl Lieberherr.
The string data type String. String (in general) A string is a sequence of characters enclosed between the double quotes "..." Example: Each character.
Working with arrays (we will use an array of double as example)
Mixing integer and floating point numbers in an arithmetic operation.
1 BUILDING JAVA PROGRAMS CHAPTER 2 Pseudocode and Scope.
Anatomy.1 Anatomy of a Class & Terminology. Anatomy.2 The Plan Go over MoveTest.java from Big Java Basic coding conventions Review with GreeterTest.java.
Chapter 2 topics Concept # on Java Subset Required for AP Exam print and println10. Testing of output is restricted to System.out.print and System.out.println.
The assignment expressions. The assignment operator in an assignment statement We have seen the assignment statement: Effect: var = expr; Stores the value.
Grade Standards, Supporting Skills, and Examples THIRD GRADE ALGEBRA Chaz Foss.
Grammars A grammar is a 4-tuple G = (V, T, P, S) where 1)V is a set of nonterminal symbols (also called variables or syntactic categories) 2)T is a finite.
AP Java 1/14/2016 Inheritance Review. Learning Objectives Be able to understand how to create classes that use inheritance. Be able to dry run programs.
Jesse proposal1 Jesse’s proposal Karl Lieberherr.
Loops. About the Midterm Exam.. Exam on March 12 Monday (tentatively) Review on March 5.
Iterators. Iterator  An iterator is any object that allows one to step through each element in a list (or, more generally, some collection).
1 Assignment 2: AspectJ. 2 The simple language Tiny program y=2; x=2+y*3; z=x+y*2; –A program is a sequence of assignments; –Expressions on the right.
CS 106 Introduction to Computer Science I 02 / 15 / 2008 Instructor: Michael Eckmann.
ELIMINATING UNIT PRODUCTIONS
Chapter 3 – Describing Syntax
Describing Syntax and Semantics
Solving Equations Conceputally
Today’s topic: Arithmetic expressions.
Proving trigonometric identities, part II
Expression Trees Eric Roberts CS 106B March 4, 2013.
Chapter 3 – Describing Syntax
Sequences and Iterators
Mathsercise-C Ready? Equations 2 Here we go!.
Maha AlSaif Maryam AlQattan
For John.
Functions.
Demeter Aspects Who We Are Aspectual Collaborations
Context Free Languages
Expressions and Control Flow in JavaScript
Presentation by Julie Betlach 7/02/2009
מערכת הרבייה באדם ערכו וכתבו: אורית עמיאל-שרון והעיקר האהבה
Is AP a sound methodology compared to OO?
OPERATORS (1) CSC 111.
DemeterJ Collaborative Behavior (using DJ) .prj ProjectControl
March 29th Odds & Ends CS 239.
ADAPTIVE PROGRAMMING Sezen ERDEM December 2005.
"First things first, but not necessarily in that order " -Dr. Who
Lecture 15 (Notes by P. N. Hilfinger and R. Bodik)
Objective caml Daniel Jackson MIT Lab for Computer Science 6898: Advanced Topics in Software Design March 18, 2002.
Lecture 7: Introduction to Parsing (Syntax Analysis)
Third lecture Review Visitor pattern DemeterJ 12/25/2018 SD.
Midterm Review CSU 670 Spring 2004.
AP/DJ AP: a generic technology
Chap. 3 Functions Start Python IDLE (Shell) and open a new file.
Compiler design.
Factoring quadratic expressions
Better Separation of Crosscutting Concerns with Aspectual Components
Third lecture Review Visitor pattern DemeterJ 2/17/2019 SD.
Chapter 4: Lexical and Syntax Analysis Sangho Ha
Context Objects Evolution of object behavior Behavioral patterns
Lecture 8 Evolution of object behavior Behavioral patterns
AOSD and the Law of Demeter: Shyness in Programming
Linear Programming Excel Solver.
Lecture 15 Doubly Linked Lists CSE /26/2018.
Bottom-up parsing is also known as shift-reduce parsing
Java Statements B.Ramamurthy CS114A, CS504 4/23/2019 BR.
Midterm CSG270 Spring 2007 Karl Lieberherr.
Quiz 11 February 13, 2019.
Variables.
Identities.
Presentation transcript:

Midterm Winter 2002 Karl Lieberherr

CSU 670 has just been renamed from motivation: Software Design and Development to Advanced Pattern Matching and Brain Exercise motivation: software development will change, but your pattern matching skills will be useful for the rest of your lives

Three-way pattern matching Our brains are good at matching patterns Given two instances of a pattern, find the correspondences between the instances and the pattern pattern = class dictionary instance 1: sentence instance 2: object

pointcut X1(S s1) : this(s); sentence AspectJFragment = <pointcuts> List(PointCut) EOF. PointCut = "pointcut" PCName <lhs> PCList(ArgDecl) ":" <rhs> PCExp ";". PCName = Ident. PCList(S) ~ "(" S { "," S } ")". List(S) ~ {S}. ArgDecl = <t> Type Variable. Type = Ident. Variable = Ident. class dictionary : AspectJFragment ( <pointcuts> : UNKNOWN-PARSE1 { <first> : Nonempty_PointCut_List ( <it> : UNKNOWN-PARSE2 ( <pcname> : UNKNOWN-PARSE3 ( <ident> : Ident "UNKNOWN-PARSE4" ) <lhs> : ArgDecl_PCList { <first> : Nonempty_ArgDecl_PCList ( <it> : UNKNOWN-PARSE5 ( <t> : UNKNOWN-PARSE6 ( <ident> : Ident "UNKNOWN-PARSE7" ) <variable> : UNKNOWN-PARSE8 ( <ident> : Ident "UNKNOWN-PARSE9" ) ) ) } object

pointcut X1(S s1) : this(s); sentence AspectJFragment = <pointcuts> List(PointCut) EOF. PointCut = "pointcut" PCName <lhs> PCList(ArgDecl) ":" <rhs> PCExp ";". PCName = Ident. PCList(S) ~ "(" S { "," S } ")". List(S) ~ {S}. ArgDecl = <t> Type Variable. Type = Ident. Variable = Ident. class dictionary : AspectJFragment ( <pointcuts> : UNKNOWN-PARSE1 { <first> : Nonempty_PointCut_List ( <it> : UNKNOWN-PARSE2 ( <pcname> : UNKNOWN-PARSE3 ( <ident> : Ident "UNKNOWN-PARSE4" ) <lhs> : ArgDecl_PCList { <first> : Nonempty_ArgDecl_PCList ( <it> : UNKNOWN-PARSE5 ( <t> : UNKNOWN-PARSE6 ( <ident> : Ident "UNKNOWN-PARSE7" ) <variable> : UNKNOWN-PARSE8 ( <ident> : Ident "UNKNOWN-PARSE9" ) ) ) } establish correspondence object establish correspondence using colors

pointcut X1(S s1) : this(s); sentence AspectJFragment = <pointcuts> List(PointCut) EOF. PointCut = "pointcut" PCName <lhs> PCList(ArgDecl) ":" <rhs> PCExp ";". PCName = Ident. PCList(S) ~ "(" S { "," S } ")". List(S) ~ {S}. ArgDecl = <t> Type Variable. Type = Ident. Variable = Ident. class dictionary : AspectJFragment ( <pointcuts> : UNKNOWN-PARSE1 { <first> : Nonempty_PointCut_List ( <it> : UNKNOWN-PARSE2 ( <pcname> : UNKNOWN-PARSE3 ( <ident> : Ident "UNKNOWN-PARSE4" ) <lhs> : ArgDecl_PCList { <first> : Nonempty_ArgDecl_PCList ( <it> : UNKNOWN-PARSE5 ( <t> : UNKNOWN-PARSE6 ( <ident> : Ident "UNKNOWN-PARSE7" ) <variable> : UNKNOWN-PARSE8 ( <ident> : Ident "UNKNOWN-PARSE9" ) ) ) } establish correspondence object

For phases 3 and 4: List Structure List(X) first X_List NonEmpty_X_List next it X

pointcut UNKNOWN-PRINT1 (A UNKNOWN-PRINT2, B UNKNOWN-PRINT3, C c3) : sentence PointCut = "pointcut" PCName <lhs> PCList(ArgDecl) ":" <rhs> PCExp ";". PCName = Ident. PCList(S) ~ "(" S { "," S } ")". ArgDecl = <t> Type Variable. Type = Ident. Variable = Ident. class dictionary <it> : PointCut ( <pcname> : PCName ( <ident> : Ident "X3" ) <lhs> : ArgDecl_PCList { <first> : Nonempty_ArgDecl_PCList ( <it> : ArgDecl ( <t> : Type ( <ident> : Ident "A" ) <variable> : Variable ( <ident> : Ident "a1" ) ) <next> : Nonempty_ArgDecl_PCList ( object

Two-way pattern matching Given a pattern and and a use of it, find correspondences between pattern and usage. pattern = method usage = inlined code

Iterator it = used.iterator(); while (it.hasNext()){ Variable curvar = (Variable) it.next(); System.out.println(); curvar.print(); } java.util.Collection used void static UNKNOWN-ABS3 show(UNKNOWN-ABS4) { UNKNOWN-ABS5 while (it.hasNext()){ UNKNOWN-ABS6 System.out.println(); curvar.print(); } establish correspondence make method as general as possible! Who supports iterator()?

Two-way pattern matching Given a pattern and and a use of it, find correspondences between pattern and usage. pattern = a programming pattern usage = an application in a specific context

DJ programming pattern: AspectJFragment { {{ // method process finds all Compound-objects inside // an AspectJFragment-object and prints the message: // "This is a Compound expression: " // for each Compound-object. void process() { UNKNOWN-AP1; Main.cg.UNKNOWN-AP2(UNKNOWN-AP3, UNKNOWN-AP4, cV); } }} CommandVisitor cV = new CommandVisitor(); this "from AspectJFragment to Compound" DJ programming pattern: class-graph.traverse(what, where-to-go, what-to-do) what = an object where-to-go = a traversal strategy what-to-do = a visitor

establish correspondence CommandVisitor { {{ // prints the message: // "This is a Compound expression: " // for each Compound-object. void UNKNOWN-AP5(UNKNOWN-AP6){ System.out.println("This is a Compound expression: "); host.print(); System.out.println(); } }} Compound host Selective visitor pattern: Visitor { {{ void before (X host) { … use host … }; void after (X host) { … use host … }; }} } establish correspondence

Traversal strategy pattern: from A via X via Y to B AspectJFragment { {{ // Find all Variable-objects on the left-hand-side // (before the colon) of PointCut-objects static String definedVarsSpec = UNKNOWN-AP7 Answer: from AspectJFragment via PointCut via -> *,lhs,* to Variable"; Traversal strategy pattern: from A via X via Y to B AspectJFragment = <pointcuts> List(PointCut) EOF. PointCut = "pointcut" PCName <lhs> PCList(ArgDecl) ":" <rhs> PCExp ";". PCName = Ident. PCList(S) ~ "(" S { "," S } ")". List(S) ~ {S}. ArgDecl = <t> Type Variable. Type = Ident. Variable = Ident.