Classes and Inheritance in Actor Oriented Models Stephen

  • Slides: 20
Download presentation
Classes and Inheritance in Actor. Oriented Models Stephen Neuendorffer Edward Lee UC Berkeley Chess

Classes and Inheritance in Actor. Oriented Models Stephen Neuendorffer Edward Lee UC Berkeley Chess Review May 8, 2003 Berkeley, CA

Introduction • Component-based design – Object-oriented components – Actor-oriented components • Most Actor-oriented tools

Introduction • Component-based design – Object-oriented components – Actor-oriented components • Most Actor-oriented tools lack the class mechanisms of Object-oriented languages. – inheritance – subclassing • A preliminary approach to providing classlike mechanisms in Ptolemy II Chess Review, May 8, 2003 2

Component-based Design Component Complex systems built primarily through composition. Encapsulation of intellectual property. Visual

Component-based Design Component Complex systems built primarily through composition. Encapsulation of intellectual property. Visual languages and design tools. Component reuse. Chess Review, May 8, 2003 3

Object-Oriented Components Provides ports expose methods that can be invoked on this object Object

Object-Oriented Components Provides ports expose methods that can be invoked on this object Object Requires ports expose methods that this object might invoke. This interface specification allows for consistency checking of compositions. However, this interface lacks important pieces of information: • Method Requirements. (Sequencing? Preconditions? ) • Concurrency constraints. (Deadlock? Re-entrancy? ) Chess Review, May 8, 2003 4

Actor-Oriented Components Input ports expose flows of data that this actor consumes. Actor Output

Actor-Oriented Components Input ports expose flows of data that this actor consumes. Actor Output ports expose flows of data that this actor produces. This interface specification allows for consistency checking of compositions. This interface also lacks important pieces of information: • How data is transported between ports • Concurrency constraints between actors These are largely orthogonal issues for actors Chess Review, May 8, 2003 5

Example of an Actor-Oriented Framework: Simulink basic abstraction mechanism is hierarchy. Chess Review, May

Example of an Actor-Oriented Framework: Simulink basic abstraction mechanism is hierarchy. Chess Review, May 8, 2003 6

Hierarchical Abstraction • Complex components can encapsulate smaller components. container hierarchical component container copy

Hierarchical Abstraction • Complex components can encapsulate smaller components. container hierarchical component container copy • Objectoriented delegation pattern Chess Review, May 8, 2003 7

Class mechanisms • Realization: – Most components in a large system operate in the

Class mechanisms • Realization: – Most components in a large system operate in the same basic fashion. • Object-oriented classes provide several important capabilities. – – Central point of design. Basis for type checking. Static compilation. Extension and variation. • But also present some complications. – Run-time modifications become difficult. – Source of inconsistencies. Chess Review, May 8, 2003 8

Classes and Hierarchy • Classes simplify the structure of complex models. • Classes extend

Classes and Hierarchy • Classes simplify the structure of complex models. • Classes extend the containment hierarchy with an inheritance hierarchy. Chess Review, May 8, 2003 9

The First (? ) Actor-Oriented Programming Language (1966) MIT Lincoln Labs TX-2 Bert Sutherland

The First (? ) Actor-Oriented Programming Language (1966) MIT Lincoln Labs TX-2 Bert Sutherland with a light pen Partially constructed actor-oriented model with a class definition (top) and instance (below). Bert Sutherland used the first acknowledged object-oriented framework (Sketchpad, created by his brother, Ivan Sutherland) to create the first actororiented programming framework. Chess Review, May 8, 2003 10

Key Problems • Direct manipulation user interface of both classes and instances. – Maximize

Key Problems • Direct manipulation user interface of both classes and instances. – Maximize syntactic consistency. • Expressive uses of classes – subclasses with extension and overriding – nested classes • Interactive modification of classes – Classes might be modified at runtime • Distinguishing overridden values from inherited default values. Chess Review, May 8, 2003 11

Visual Class Representation Each block is implicitly an instance of an actor class. Chess

Visual Class Representation Each block is implicitly an instance of an actor class. Chess Review, May 8, 2003 12

An Actor Class Every subclass or instance of this actor class contains at least

An Actor Class Every subclass or instance of this actor class contains at least this structure. Parameter values of actors in a class give default values for all instances of the class Chess Review, May 8, 2003 13

Models with Classes Actor classes are explicitly instantiated. model class instance Derived objects implied

Models with Classes Actor classes are explicitly instantiated. model class instance Derived objects implied by class instance Intuition: Modifications to classes propagate to derived objects, as long as local changes have not been made. Chess Review, May 8, 2003 14

A Simple Example Here the property of Base. Class is modified, which does not

A Simple Example Here the property of Base. Class is modified, which does not propagate to Instance 2. This example is simple because there is only one propagation path. Chess Review, May 8, 2003 15

A Subclass Dotted lines show inherited objects that cannot be deleted, while allowing syntax-directed

A Subclass Dotted lines show inherited objects that cannot be deleted, while allowing syntax-directed editing. Chess Review, May 8, 2003 16

Models with Sub. Classes Actor classes are explicitly subclassed. model class subclass instance Derived

Models with Sub. Classes Actor classes are explicitly subclassed. model class subclass instance Derived objects implied by class instance Changes propagate to subclasses similarly to instances. Subclasses allow for independent extension, while instances do not. Chess Review, May 8, 2003 17

Nested Classes Chess Review, May 8, 2003 18

Nested Classes Chess Review, May 8, 2003 18

Models with Nested Classes model class instance Nested classes result in multiple propagation paths.

Models with Nested Classes model class instance Nested classes result in multiple propagation paths. Approach: prioritize propagation so that localized changes override global changes. Chess Review, May 8, 2003 19

Summary • Class mechanisms for modularity can be integrated with actor-oriented modeling. • Inherited

Summary • Class mechanisms for modularity can be integrated with actor-oriented modeling. • Inherited changes in a syntactically-driven environment can be tricky: – Nested Classes • Still many open questions. . – Consistency given multiple propagations? – Is “Local Override” property the best one? Chess Review, May 8, 2003 20