Principles of Object-Oriented

handprintΛογισμικό & κατασκευή λογ/κού

18 Νοε 2013 (πριν από 3 χρόνια και 8 μήνες)

63 εμφανίσεις

Principles of Object
-
Oriented
Software Development

Object
-
oriented programming
languages

Object
-
oriented programming
languages



Introduction



The object paradigm


Comparing Smalltalk, Eiffel, C++ and Java


Design dimensions of object
-
oriented languages


Prototypes
--

delegation versus inheritance


Meta
-
level architectures



Summary


Q/A


Literature

Object
-
oriented

programming languages


the object paradigm


language design dimensions


classless prototypes


meta
-
level architectures

Additional keywords and phrases:

programming languages, orthogonality, reliability, complexity,
types, delegation, multiple paradigms, prototypes, reflection

The object paradigm

Subsections:



A classification of object
-
oriented languages


Alternative object models


Object extensions of Lisp, C and Prolog


Script languages
--

integration with Java

The notion of object


abstract data types
--

software engineering


frames
--

artificial intelligence


semantic data models
--

database system
development


capability
-
based computing
--

distributed
systems


Simula

object
-
oriented

structurally



capability of representing arbitrarily structured complex objects


operationally



the ability to operate on complex objects through generic operators


behaviorally



the specification of types and operations (data abstraction)

Perspectives of object orientation

A classification of


object
-
oriented languages



Objects


object creation facility


message passing capability


class capability


inheritance features


language characteristics

Classification


hybrid
--

C, Lisp, Pascal, Prolog


frame
-
based
--

knowledge
-
based reasoning


distributed, concurrent, actor
--

parallel
computing


alternative object models
--

prototypes,
delegation

Alternative object models



Object extensions of Lisp, C and
Prolog

Object extensions



Lisp
--

LOOPS, FLAVORS, CLOS, FOOPS


C
--

Objective C, C++


Prolog
--

SPOOL, VULCAN, DLP


Commercial products
--

languages



Smalltalk, Eiffel, C++, Objective C, Object Pascal, Java


Object structure
--

efficient mapping



C++





struct A { ... } == class A { public: ... }


class A { ... } == struct A { private: … }











The equivalence between class and struct

Script languages Java embedding








Javascript
--

Dynamic HTML




Perl
--

CGI/Web library JPL



Tcl/Tk
--

tclets Jacl, Tcl Blend




Python
--

Grail JPython

Objects in Javascript




<script language=Javascript> javascript



function object_display(msg) { object method


return msg + ' (' + this.variable++ + ')';


}




function object() { object constructor


this.variable=0;


this.display = object_display;


return this;


}




var a = new object(); create object



document.write(a.display("a message"));


document.write(a.display("another message"));


</script>

Comparing Smalltalk, Eiffel,
C++ and Java

Subsections:



Criteria for comparison


Language characteristics

Criteria for comparison


class libraries


programming environment


language characteristics

Language characteristics


uniformity of data structures


documentation value


reliability


inheritance mechanisms


efficiency


memory management


language complexity



Smalltalk Eiffel C++ Java






uniformity high medium low medium


documentation value medium high medium high


reliability medium medium low* high*


protected operations no no yes yes


multiple inheritance no yes yes no*


efficiency low medium high low


garbage collection yes yes no* yes


language complexity low* medium high medium



Design dimensions of


object
-
oriented languages

Subsections:



Object
-
based versus object
-
oriented


Towards and orthogonal approach
--

type extensions


Multi
-
paradigms languages
--

logic


Active objects
--

synchronous Java/C++


Object Oriented Language

Design


object: state + operations


class: template for object creation


inheritance: super/base and subclasses


object
-
oriented =


objects + classes + inheritance

data abstraction
--

state accessible by operations

strong typing
--

compile time checking

Orthogonal approach


objects
--

modular computing agents


types
--

expression classification


delegation
--

resource sharing


abstraction
--

interface specification


Multi
-
paradigm languages


logic

Open systems



reactive
--

flexible (dynamic) choice of actions


modular
--

(static) scalability


Dimensions of modularity



encapsulation boundary
--

interface to client


distribution boundary
--

visibility from within objects


concurrency boundary
--

threads per object, synchronization


Active objects

synchronous Java/C++

Object
-
based concurrency


add processes
--

synchronization


multiple active objects
--

rendezvous


asynchronous communication
--

message
buffers

Synchronous C++/Java


active class S { sC++


public:


m () { ... }


private:


@S () { pseudo
-
constructor


select {


01
-
> m(); external call


instructions ...


||


accept m; accept internal method


instructions ...


||


waituntil (date); time
-
out


instructions ...


||


default default


instructions ...


} } }



Prototypes

delegation versus inheritance

Subsections:



Alternative forms of sharing


Implementation techniques
--

Self

Prototypes


cloning
--

creation time sharing


delegation
--

lifetime sharing

exemplars

State



slots
--

parents, variables and methods


Creation



shallow cloning


deep cloning


Delegation



implicit delegation


explicit delegation


Improving performance


special purpose hardware


hybrid languages


static typing


dynamic compilation


Implementation techniques
--

Self

Self
--

prototypes



objects, cloning, delegation


Dynamic compilation
--

type information



customized compilation


message inlining


lazy compilation


message splitting

Implementation techniques
--

Self

Meta
-
level architectures



The class concept


abstract data type
--

interface description


object generator
--

template for creation


repository
--

for sharing resources


object
--

instance of a metaclass


Postulates


everything is an object


every object belongs to a class


every class inherits from the class Object


class variables of an object are instance
variables of its class

class
-
based languages

Reflective definition of Class


name Class


supers (Object)


iv (name supers iv methods)


methods (new ...)



Summary

The object paradigm


notion of object
--

viewpoints


classification
--

object extensions


1

Comparing Smalltalk,

Eiffel, C++ and Java


criteria
--

libraries, environments, language
characteristics


comparison
--

language characteristics


2

Design dimensions of

object
-
oriented languages


object
-
oriented
--

object
-
based + inheritance


orthogonal dimensions
--

objects, types,
delegation, abstraction


open systems
--

dimensions of modularity


3

Prototypes
--

delegation

versus inheritance


prototypes
--

cloning and delegation


performance
--

dynamic compilation


4

Meta
-
level architectures


class
--

the concept of class


meta architecture
--

subclass and instance
hierarchy


reflection
--

postulates


5

Questions

1. What are the basic characteristics of object
-
oriented languages?

2. How would you classify object
-
oriented languages? Name a few
representatives of each category.

3. What do you consider to be the major characteristic of the object
model supported by C++? Explain.

4. Why would you need friends?

5. How would you characterize the difference between object
-
based and
object
-
oriented?

6. Along what orthogonal dimensions would you design an object
-
oriented language? Explain.

7. Give a characterisation of active objects. In what situations may active
objects be advantageous?

8. How would you characterize prototype
-
based languages?


9. What are the differences between inheritance and delegation? Does
C++ support delegation? Explain. And Java?

10. How would you characterize the concept of a class?

11. Can you sketch the meta architecture of Smalltalk?

12. How would you phrase the postulates underlying class
-
based
languages? Can you give a reflective version of these postulates?

Further reading

A concise treatment of programming languages is given in
[BG94]. Further, you may want to consult [Wegner87], which
contains the original presentation of the discussion concerning the
distinction between object
-
based and object
-
oriented. For Java,
read the original white paper, [Java]. An interesting extension of
C++ is described in [Petitpierre98]. At the corresponding web site,
http://ltiwww.epfl.ch/sCxx , there is much additional material.
Finally, for an account of the design and evolution of C++, read
[Stroustrup97]. For more information on C++, visit
http://www.accu.org , and for Java, http://www.javasoft.com .