Top Banner
Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo, NY 14260 http://www.cse.buffalo.edu/ LRG * Joint work with recent PhD graduates Pallavi Tambay (2003) and Paul Gestwicki (2005) and several MS students at Buffalo
63

Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Dec 22, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Research Directions in Object Oriented Languages*

Bharat Jayaraman

Professor and ChairDepartment of Computer Science & Engineering

University at Buffalo, NY 14260

http://www.cse.buffalo.edu/LRG

* Joint work with recent PhD graduates Pallavi Tambay (2003) and Paul Gestwicki (2005)

and several MS students at Buffalo

Page 2: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Programming Languages

Imperative Declarative

Procedural Data Abstraction

C …Fortran ObjectsModules

Ada … Java …

Relational Functional

Constraints Logic ML …

CLP … Prolog …

… …

Page 3: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Two Research Projects

I. Modeling Complex Systems

II. Interactive Visualization

Page 4: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

I. Modeling Complex Systems

• Motivating Domains Engineering Organizational Biological …

• Common Characteristics Assembly of components Laws of behavior Natural visual representations

Page 5: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Building Elements

(Kalay et al 1998)

Page 6: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Examples of Laws/Constraints

• “The load on a wall ≤ its load bearing capacity.”

• “The sum of the forces at a joint should be zero.”

• Various other constraints, such as:- ‘mate’ constraints- ‘flush’ constraints- ‘angle’ constraints

etc.

Page 7: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Our Principles of Modeling

• compositional specification of structure

objects• declarative specification of behavior

constraints• visual specification of assembly

diagrams

Page 8: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

I. Constrained Objects

• An object is a container of data that is accessed via a well-defined interface of procedures. (Imperative)

• A constrained object contains data that is governed by laws, or constraints. (Declarative)

• Examples: resistor in a circuit a joint in a truss a cell in a spreadsheet

Page 9: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Constraints• A constraint is a declarative relation among

variables, e.g.,F = 32 + 1.8*C

• Constraints are additive, and collectively enforce the conditions among variables

D ≥ 1 D ≤ 31 D ≤ 29 ← M = 2 /\ leapyear(Y)

• Many algorithms for constraint satisfaction

Page 10: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

1. Circuits as Constrained Objects

V1 = I1 * R1

V2 = I2 * R2

V3 = I3 * R3

V1 =V2 = V3 = V

I1 + I2 + I3 = I

1/R1 + 1/R2 + 1/R3 =1/R

V = I * R

Page 11: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Overview of Cob Programs

class class_id [ extends class_id ] { attributes attributes

constraints constraints

constructor constructor_clauses

}

Class inheritance

equations, inequations,conditional,quantified,aggregate

Page 12: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Cob Class Definitions

class component { attributes Real V, I, R; constraints V = I * R; constructor component(V1, I1, R1) { V = V1; I = I1; R = R1; }}

Ohm’s Law

class parallel extends component {attributes component [ ] C; constraints forall X in C: (X.V = V); (sum X in C: X.I) = I; (sum X in C: 1/X.R) = 1/R; constructor parallel(P) { C = P; }}

Page 13: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

2. Truss as Constrained Object

Load Load

Beam Joint

Page 14: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

class joint { attributes bar [ ] Bars; load [ ] Loads; constraints (sum X in Bars : X.B.F * sin(X.A)) + (sum L in Loads : L.F * sin(L.A)) = 0;

(sum Y in Bars : Y.B.F * cos(Y.A)) + (sum M in Loads : M.F * cos(M.A)) = 0;

constructor joint(B1, L1) { Bars = B1; Loads = L1; }}

Law of Equilibrium of Forces

Page 15: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

class bar {attributes beam B; real A; constraints 0 A; A 360; constructor bar (B1, A1)

{ B = B1; A = A1; }}

class load { attributes real F, A; constraints 0 A; A 360; constructor load (F1, A1)

{ F = F1; A = A1; }}

Page 16: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

class beam { attributes real E, Sy, L, W, H, F_bn, F_bk, F_t, Sigma, I, F; constraints Pi = 3.141; I = F_bk * L* L / (Pi * Pi * E) ; I = W * H * H * H / 12; F_t = Sy * W * H; Sigma = H * I * F_bn / (8 * I); F = F_t :- F > 0; F = F_bk :- F < 0; constructor beam(E1, Sy1, L1, W1, H1,F1) { E = E1; L = L1; H=H1; W=W1; F = F1; }}

ConditionalConstraint

Page 17: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Overall Modeling Scenario

modeling ::= define_classes ;

build_instance ;

solve_instance ;

[ [ modify ; re_solve ] +;

query * ] +

Page 18: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Modeling Tools • Constrained Object Language (Cob)

Text-based language

• Constraint-Based UML (CUML) Domain-independent graphical modeling language

• Domain-Specific Visual Programming Diagrammatic notations customized for specific application

domains, e.g., circuits, trusses, etc.

Page 19: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

(with R. Jotwani)

CUML: Constraint-based UML

Page 20: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

CUML Cob

Page 21: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

(with A. Dev and N. Menon)

`

Domain-Specific Visual Language

Page 22: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

cse@buffalo13

resistor value

extraconstraint

changeresistorbehavior

Page 23: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

R1 isunknown

outputconstraint

Page 24: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Compiled CUML Code

Compiled Circuit Diagram Code

Cob Compiler

CLP® Code

Optimizer

Optimized Code

ConstraintEngine

Answers

DiagramManager

Page 25: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

CUML Class Diagram

Compiler

Textual Cob Code

By Chinchani, Pramanik, Dutta

Page 26: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Circuit Diagram

Compiler

Textual Code

Page 27: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Optimized Code (by partial evaluation of generated code)

V1 = V2 = I1 * 10 = I2 * 20 V3 = V4 = I3 * 20 = I4 * 20 S.I = I1 + I2 = I3 + I41/P1.R = 1/10 + 1/ 20V3 = S.I * P2 .R1/P2.R = 1/20 + 1/2030 = S.I + S.R30 = V1 + V3S.R = P1.R + P2.R

Page 28: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Building Elements (Kalay 1998)

Page 29: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Overall Class Diagram

Page 30: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

class building { attributes level[] Ls; real Area; constraints Area = sum X in Ls: X.Area; constructor building(L) { Ls = L; }}

Class Building

Area of the building is the sum of areas of each level

Page 31: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Class Slabclass slab { attributes level Pl; beam[ ] Peripheralbeams; real Z; constraints forall B in Peripheralbeams: B.Z = Z; constructor slab(L,B) { Pl = L; Peripheralbeams = B; }}

The height of all beams surrounding the slab must be the same

Page 32: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Two-level House (Kalay et al)

Page 33: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Cob Representation for a Space space Spaces00; slab[] Slabs0; slab[] Slabs1; surface[] Surfaces00; beam[] Beams01; slab Slabs00; surface Surfaces003, Surfaces002; surface Surfaces001, Surfaces000; horizontalSurface Ceiling00; horizontalSurface Floor00; beam B014, B013,B012, B011 ; edge Edge003, Edge002; edge Edge001, Edge000; wall Wall007, Wall002; wall Wall001, Wall000; column C8,C4, C6, C2; vertex V8, V7, V6, V5; vertex V26, V30, V36, V31; level Level0;

All the elements needed to depict Spaces00 (green)

Page 34: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Wall007 = new wall( V7, V8, 3.0, B014 );Wall002 = new wall( V6, V7, 3.0, B013 );Wall001 = new wall( V5, V6, 3.0, B012 );Wall000 = new wall( V8, V5, 3.0, B011 );Slabs10 = new slab( Level1, Beams10 );Slabs00 = new slab( Level0, Beams00 );B012 = new beam( V5, V6, B014, _ );B011 = new beam( V8, V5, B013, _ );B014 = new beam( V7, V8, B012, _ );B013 = new beam( V6, V7, B011, _ );C4 = new column( V6, V50 );C6 = new column( V8, V51 );C2 = new column( V5, V46 );C8 = new column( V7, V55 );Edge003 = new edge( Surfaces003, V7, Edge011 );Edge002 = new edge( Surfaces002, V6, _ );Edge001 = new edge( Surfaces001, V5, _ );Edge000 = new edge( Surfaces000, V8, _ );V36 = new vertex( V55, C8, 5.0, 5.0, 3.0 );V8 = new vertex( V31, _, 5.0, 0.0, 0.0 );V31 = new vertex( V51, C6, 5.0, 0.0, 3.0 );V7 = new vertex( V36, _, 5.0, 5.0, 0.0 );V30 = new vertex( V50, C4, 0.0, 5.0, 3.0 );V6 = new vertex( V30, _, 0.0, 5.0, 0.0 );V5 = new vertex( V26, _, 0.0, 0.0, 0.0 );V26 = new vertex( V46, C2, 0.0, 0.0, 3.0 );dump([Level0 .Vol]);

Cob Representation (cont)

Page 35: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Observations• Constrained objects represent nicely the structure and constraints

arising in intelligent building representations.

• The model described in this presentation has been implemented and works in a predictable way.

• The current approach, even when applied to a simple two-level house with five spaces, is still tedious and error prone.

• There is a need for a higher-level specification from which Cob code can be generated Component-based Design

• Inconsistency analysis and debugging are very important

Page 36: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Conclusions and Further Work

• Constrained Objects ≥ Constraints + Objects• Applicable in many domains• Facilitates true visual programming

• Model Analysis and Fault Detection• Dynamic and Evolving Systems• Intelligent Visualizations

Page 37: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

II. Interactive Visualization of OO Programs

• Conventional Execution Model: data objects and procedure activations are in

separate spaces.• Object-Oriented Execution Model: procedure activations occur inside data objects,

i.e., objects are execution environments• Several more criteria for a good visualization

system for OOPs …

Page 38: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Binary Search Tree in Java

class Tree {public Tree(int n) { value = n; left = null; right = null; }protected int value;protected Tree left;protected Tree right;}

public void insert(int n) { if (value == n) return; if (value < n) if (right == null) right = new Tree(n); else right.insert(n); else if (left == null) left = new Tree(n); else left.insert(n); }

Page 39: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Tree

Tree Tree

Tree Tree Tree Tree

1

2 3

4 5 6 7

Page 40: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Tree

Tree Tree

Tree Tree Tree Tree

1

2 3

4 5 6 7

insert1

insert3

2insert

Page 41: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Treei

value

left

right

Tree

insert

int

Tree

Tree

const

proc

insertj

n

rpdl

int

insert in Tree k n

Tree i

Page 42: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Visualization Criteria• Object as environments• Multiple View of Objects• Aesthetic Drawing• Forward and Reverse Execution• History of Execution• Support Run-time Queries• Use Existing Compiler and Run-time System

Page 43: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

JIVE: Java Interactive Visualization Environment

Page 44: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

JIVE supports Source Code Highlighting, Break Points, andForward as well asReverse Steppingof Programs

Page 45: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

JIVE Interaction Controls

Forward and Fast Forward Buttons

Reverse and Fast Reverse Buttons

Minimize, Maximize,Compact View

Call Path View

Page 46: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,
Page 47: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Displayingonly the‘Call Path’

Page 48: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,
Page 49: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Object Diagram without Inherited Objects

Page 50: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Minimized Object Diagram

Page 51: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Final Object Diagram

Page 52: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Final Minimized Diagram

Page 53: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

TimeSequenceDiagram- to capturethe historyof methodcalls betweenobjects

Page 54: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Tree Program with GUI front-end

Page 55: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Tree Programwith GraphicalUser Interface

Page 56: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,
Page 57: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

SelectiveExpansionofObjectDiagram

Page 58: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Querying the Runtime State

Runtime

Query

“Which variable has the value 50?”

Answer toQuery

Page 59: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Visual Display of Query Result

Object BST:2has the answer

Exact pointof assignment

Page 60: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Visual Display of Query Result

“Variable V in Object BST:2 has the value 50!”

Page 61: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Show all changes to variable ‘left’

Page 62: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Concluding Remarks• Diagrams clarify Java semantics

handles advanced features• Visualization environment

pedagogic tool visual debugger

• JPDA is key to the implementation• Some research issues

Aesthetic drawing Efficient reverse stepping

Page 63: Research Directions in Object Oriented Languages* Bharat Jayaraman Professor and Chair Department of Computer Science & Engineering University at Buffalo,

Current and Future Work

• Reverse execution and efficient state-saving• Drawing algorithms• Visual Queries• Relationship between programs and diagrams• Applications in Security