Principles of ObjectOriented Software Development Objectoriented programming languages
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 Simula • abstract data types -- software engineering • frames -- artificial intelligence • semantic data models -- database system development • capability-based computing -- distributed systems
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 language characteristics • • object creation facility message passing capability class capability inheritance features
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> function object_display(msg) { return msg + ' (' + this. variable++ + ')'; } function object() { this. variable=0; this. display = object_display; return this; } var a = new object(); document. write(a. display("a message")); document. write(a. display("another message")); </script> javascript object method object constructor create object
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 uniformity high documentation value medium reliability medium protected operations no multiple inheritance no efficiency low garbage collection yes language complexity low* Eiffel C++ medium high medium no yes medium low* yes high no* high Java medium high* yes no* low yes 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 { public: m () {. . . } private: @S () { select { 01 -> m(); instructions. . . || accept m; instructions. . . || waituntil (date); instructions. . . || default instructions. . . }}} s. C++ pseudo-constructor external call accept internal method time-out default
Prototypes delegation versus inheritance Subsections: Alternative forms of sharing Implementation techniques -- Self
Prototypes exemplars • cloning -- creation time sharing • delegation -- lifetime sharing
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 class-based languages • • 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
Reflective definition of Class name supers iv methods Class (Object) (name supers iv methods) (new. . . )
Summary
1 The object paradigm • notion of object -- viewpoints • classification -- object extensions
2 Comparing Smalltalk, Eiffel, C++ and Java • criteria -- libraries, environments, language characteristics • comparison -- language characteristics
3 Design dimensions of object-oriented languages • object-oriented -- object-based + inheritance • orthogonal dimensions -- objects, types, delegation, abstraction • open systems -- dimensions of modularity
4 Prototypes -- delegation versus inheritance • prototypes -- cloning and delegation • performance -- dynamic compilation
5 Meta-level architectures • class -- the concept of class • meta architecture -- subclass and instance hierarchy • reflection -- postulates
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 objectoriented 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 [BG 94]. Further, you may want to consult [Wegner 87], 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 [Petitpierre 98]. At the corresponding web site, http: //ltiwww. epfl. ch/s. Cxx , there is much additional material. Finally, for an account of the design and evolution of C++, read [Stroustrup 97]. For more information on C++, visit http: //www. accu. org , and for Java, http: //www. javasoft. com.
- Slides: 47