Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 1 Object-Oriented Programming Languages Principles of Object-Oriented Software.

Slides:



Advertisements
Similar presentations
Understand and appreciate Object Oriented Programming (OOP) Objects are self-contained modules or subroutines that contain data as well as the functions.
Advertisements

Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
OBJECT ORIENTED PROGRAMMING M Taimoor Khan
Classes & Objects Computer Science I Last updated 9/30/10.
Object-Oriented Analysis and Design
Object-Oriented PHP (1)
Programming Language Paradigms: summary. Object-oriented programming Objects are the fundamental building blocks of a program. Interaction is structured.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Principles of Object-Oriented Software Development The language Eiffel.
Principles of Object-Oriented Software Development Object-oriented programming languages.
Reasons to study concepts of PL
ISBN Chapter 1 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Chapter 1 Topics Motivation Programming Domains.
Scripting Languages For Virtual Worlds. Outline Necessary Features Classes, Prototypes, and Mixins Static vs. Dynamic Typing Concurrency Versioning Distribution.
Object-Oriented Databases
Programming Languages Structure
ISBN Lecture 01 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Lecture 01 Topics Motivation Programming.
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
Chapter 10 Classes Continued
ISBN Chapter 1 Topics Motivation Programming Domains Language Evaluation Criteria Influences on Language Design Language Categories Language.
Abstract Data Types and Encapsulation Concepts
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Object-oriented design CS 345 September 20,2002. Unavoidable Complexity Many software systems are very complex: –Many developers –Ongoing lifespan –Large.
C++ fundamentals.
Overview. Copyright © 2006 The McGraw-Hill Companies, Inc. Chapter 1 Overview A good programming language is a conceptual universe for thinking about.
Comparison of OO Programming Languages © Jason Voegele, 2003.
Programming Languages and Paradigms Object-Oriented Programming.
Classes Mark Hennessy Dept. Computer Science NUI Maynooth C++ Workshop 18 th – 22 nd Spetember 2006.
Introduction to Object-oriented programming and software development Lecture 1.
CISC6795: Spring Object-Oriented Programming: Polymorphism.
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
An Object-Oriented Approach to Programming Logic and Design
CS 363 Comparative Programming Languages
1 Chapter 10: Data Abstraction and Object Orientation Aaron Bloomfield CS 415 Fall 2005.
Unified Modeling Language, Version 2.0
JavaScript, Fourth Edition
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
Programming Languages and Paradigms Object-Oriented Programming.
Chapter 6 Object-Oriented Java Script JavaScript, Third Edition.
Introduction to Object Oriented Programming CMSC 331.
OOP Class Lawrence D’Antonio Lecture 3 An Overview of C++
Chapter 18 Object Database Management Systems. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Motivation for object.
Summing Up Object Oriented Design. Four Major Components: Abstraction modeling real-life entities by essential information only Encapsulation clustering.
9-Dec Dec-15  INTRODUCTION.  FEATURES OF OOP.  ORGANIZATION OF DATA & FUNCTION IN OOP.  OOP’S DESIGN.
Chapter 12 Support for Object-Oriented Programming.
Object-Oriented Programming Chapter Chapter
(1) ICS 313: Programming Language Theory Chapter 12: Object Oriented Programming.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
ISBN Object-Oriented Programming Chapter Chapter
1 Unified Modeling Language, Version 2.0 Chapter 2.
Principles of programming languages 10: Object oriented languages Isao Sasano Department of Information Science and Engineering.
1 Chapter 11 © 1998 by Addison Wesley Longman, Inc The Concept of Abstraction - The concept of abstraction is fundamental in programming - Nearly.
1 CS Programming Languages Class 22 November 14, 2000.
1 Copyright © 1998 by Addison Wesley Longman, Inc. Chapter 10 Abstraction - The concept of abstraction is fundamental in programming - Nearly all programming.
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
Object-Oriented Design Concepts University of Sunderland.
A Survey of Object-Oriented Concept Oscar Nierstrasz.
CSCE 240 – Intro to Software Engineering Lecture 3.
ISBN Chapter 12 Support for Object-Oriented Programming.
Principles of programming languages 10: Object oriented languages
Object Oriented Programming in Java
Object-Orientated Programming
Types of Programming Languages
Names, Binding, and Scope
Object-Oriented Programming
Programming Languages 2nd edition Tucker and Noonan
Support for Object-Oriented Programming
Presentation transcript:

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 1 Object-Oriented Programming Languages Principles of Object-Oriented Software Development (Chapter 5)

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 2 Objective l To illustrate the concepts of object-oriented programming languages in a broader context beyond the familiar Java and C++ interpretations.

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 3 Outline l The object paradigm l Comparison: Smalltalk, Eiffel, C++, Java l Dimensions of language design l Classless languages

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 4 The Notion of Object l The notion of objects appears in many areas of computer science Software engineering: Abstract data types Artificial intelligence: Frames Databases: Semantic data models Distributed systems: Capability-based computing

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 5 Perspectives on Object-Orientation l Structural Capability of representing arbitrarily structures complex objects An object is a data structure in memory l Operational The ability to operate on complex objects through generic operators An object represents an element of a conceptual model l Behavioral The specification of types and operations An object is a type, used for data abstraction

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 6 Characteristics of Object- Oriented Languages l Object creation facility Must be able to instantiate objects l Message-passing capability Must be able to communicate between objects l Class capability Must have a mechanism for defining classes l Inheritance features Must support some form of inheritance

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 7 Classifications of Object-Oriented Languages l Hybrid – extensions to existing languages O-O retrofitted to existing languages: C, Lisp, Pascal, Prolog, etc Examples: C++, CLOS, Objective Pascal, DLP l Frame-based – knowledge-based reasoning Frame – a structure consisting of slots Slot – a value of an attribute or a relation to other frames Examples: KRL, LOOPS

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 8 Classifications (continued) l Distributed, concurrent, actor – parallel computing Active object – executes in parallel with other active objects Examples: Concurrent Smalltalk, sC++, POOL-T Actor languages Instead of threads, parallel execution is realized by self- replacement Actor processes a message sent to it, and creates a successor object in its place, thus the same actor potentially takes on a different identity l Alternative object models Removes the distinction between classes and objects Everything is an object Examples: Self

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 9 Object-Oriented Scripting Languages l Many scripting languages are designed to support object-oriented programming Built-in support Embedding an O-O language l Javascript l Perl, JPL (Java-Perl module) l Tcl/Tk, Jacl (Tcl/Java) l Python, JPython

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 10 Objects in Javascript function object_display(msg) { object method return msg + ' (' + this.variable++ + ')'; } function myobject() { object constructor this.variable=0; this.display = object_display; return this; } var a = new myobject(); create object document.write(a.display("a message")); document.write(a.display("another message"));

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 11 Outline l The object paradigm l Comparison: Smalltalk, Eiffel, C++, Java l Dimensions of language design l Classless languages

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 12 Comparing Smalltalk, Eiffel, C++ and Java l Criteria Class libraries Availability of sufficient class library support Programming environment Availability of environment to support development Language characteristics

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 13 Smalltalk Example Behavior subclass: #Ctr instanceVariableNames: 'value' Ctr methodsFor: 'initialization' initialize value := 0. Ctr methodsFor: 'modifications' add: aValue value := value + aValue. Ctr methodsFor: 'inspection' value ^value

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 14 class counter export inc val feature count : Integer create is do count := 0 end inc( n : Integer ) is require n > 0 do count := count + n ensure count = old count + n end val : Integer is do Result := count end invariant count >= 0 end -- class counter Eiffel Example

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 15 C++ Example class ctr { public: ctr() { n = 0; } // constructor ~ctr() { cout << "bye"; }; // destructor void add( int i = 1) { n = n + i; } int val( ) { return n; } private: int n; }; // Usage: ctr c; c.add(1); cout << c.val(); ctr* p = new ctr(); c->add(1); cout val();

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 16 Class Libraries l Availability of sufficient class library support l Smalltalk: part of language definition l Eiffel: part of language definition l C++: STL, large number of 3 rd party libraries l Java: large number of standardized APIs

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 17 Programming Environment l What constitutes “good” programming environment? Graphical interface for novices Command line interface for experts l Smalltalk: part of language definition l Eiffel: part of language definition l C++: large number of commercial environments l Java: many popular IDEs (Eclipse, JBuilder, Visual J#, JDeveloper, NetBeans)

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 18 Language Characteristics l Uniformity of data structures l Documentation value l Reliability l Inheritance mechanism l Efficiency l Memory management l Language complexity

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 19 Comparison Table

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 20 Uniformity l Uniformity of treatment of data types l Smalltalk Every data type is a class l Eiffel Elementary data types are distinct from classes l C++ Elementary data types are distinct from classes l Java Elementary data types are distinct from classes

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 21 Documentation Value l How easy is it to read a program and to write a correct program? l Smalltalk A consistent style in writing programs because everything is a class l Eiffel Special keywords to formally specify correctness of programs and specify interfaces l C++ No constructs to support documentation Terse style is preferred by some over the more verbose languages l Java Javadoc sets a standard for documentation

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 22 Reliability l Smalltalk Dynamically typed, no type checking l Eiffel Static type checking, correctness assertions l C++ Inherits unreliability perception from C Static type checking within a compilation module, weak support across modules Consistent type system l Java Less error-prone than C++ due to absence of pointers and built- in garbage collection

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 23 Inheritance l Smalltalk Single inheritance l Eiffel Multiple inheritance l C++ Multiple inheritance l Java Single inheritance Multiple interface inheritance

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 24 Efficiency l Smalltalk –Interpreted l Eiffel +Compiled –Dynamic binding for all methods l C++ +Compiled +Inline functions, flexible memory management, friends –No garbage collection l Java –Compiled to bytecode; efficiency depends on JVM

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 25 Language Complexity l Smalltalk Generally considered low complexity l Eiffel Simple object-oriented constructs l C++ Highly complex Large language; complicated overloading l Java Designed to be less complex than C++

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 26 Outline l The object paradigm l Comparison: Smalltalk, Eiffel, C++, Java l Dimensions of language design l Classless languages

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 27 Design of Object-Oriented Languages l Object-oriented languages support the following: Object – state + operations Class – template for object creation Inheritance – sharing parts of a description Data abstraction – state accessible by operations Strong typing – compile time checking Object-oriented = objects + classes + inheritance Object-based = objects + classes

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 28 Orthogonal Dimensions l More formally, object-oriented languages can be defined by the following orthogonal dimensions: Objects – modular computing agents Supports construction of modular units to which a principle of locality applies Types – expression classification Types are a more general abstraction than classes Dynamic typing – no static type checking, only inability to evaluate an expression leads to runtime error Static typing – compile time determination and checking of the types of all variables, objects and expressions Delegation – resource sharing A mechanism that allows redirection of control dynamically A more general mechanism than forwarding a method call Examples: single inheritance, multiple inheritance, scope inheritance Abstraction – interface specification What is visible and what is hidden to other objects? External behavior specified by contracts External state specified by public or protected attributes

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 29 Open Systems l A goal of object-oriented language design is openness l A software system is said to be open if its behavior can be easily modified and extended l Reactiveness A program has a (runtime) choice between potential actions l Modularity A program can be safely extended (at design time) by adding new components

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 30 Reactiveness l A program has a (runtime) choice between potential actions l Late binding (polymorphism) provides dynamic selection of alternatives depending on the subtype l Guards in concurrent languages provide a choice for accepting or rejecting a call

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 31 Modularity l A program can be safely extended (at design time) by adding new components l Languages must provide appropriate information hiding mechanisms: Hide details of objects from outside world Usual notion of encapsulation Classes provide modularity by hiding details of the class from the outside world Hide details of outside world from objects Objects should not have to know that other objects are on the same machine or not Objects should not have to know that other objects are active

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 32 Object-based Concurrency l Object-based concurrency = objects + processes l Approaches Add processes as a primitive data type Programmer has the burden of dealing with synchronization Implement active objects Objects are simultaneously active Language provides constructs to support synchronous communications (rendezvous) Active object interrupts itself to respond to messages Potential for deadlock exists with self-invocation Performance issues if only a few active objects needed Need careful choice in determining which objects should be active Use asynchronous communication through message buffers Instead of interrupting, queue up the messages in a buffer Real-time constraints become impossible to guarantee

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 33 Outline l The object paradigm l Comparison: Smalltalk, Eiffel, C++, Java l Dimensions of language design l Classless languages

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 34 Classless Languages l Classical object model Objects are instances of classes Object-oriented = objects + classes + inheritance l Classless languages There are no classes, only objects New objects are created by cloning existing objects Objects are cloned from objects called “prototypes” Inheritance is approximated by delegation Object chooses which object to designate as parent Dynamic binding is implemented by searching up the parent list Advantages Conceptually easier to create objects from existing examples rather than defining a characterization of the object through a class Dynamic sharing of code and information is more flexible than inheritance and instantiation

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 35 Design Issues for Prototypes l State Object consists of slots Object consists of variables and methods l Creation Shallow cloning – copy the object Deep cloning – copy the object and all referenced objects l Delegation Implicit delegation – follow the parent chain Explicit delegation – object is named l Self language: slots, shallow cloning, implicit delegation

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 36 Improving Performance l In pure object-oriented languages, dynamic type checking and dynamic binding is the rule Increases flexibility Performance suffers l Solutions Special-purpose hardware Hybrid languages Create a hybrid language with a procedural language Dealing with unwanted interactions can be a complex problem Static typing Bounds the language flexibility Dynamic compilation Perform partial evaluation, lazy compilation, message splitting

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 37 Dynamic Compilation Techniques l Customized compilation l Message inlining l Lazy compilation l Message splitting

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 38 Meta-Level Architectures

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 39 The Class Concept l Abstract data type – interface description l Object generator – template for creation l Repository – for sharing resources l Object – instance of a metaclass

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 40 Meta Architectures

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 41 Postulates – class-based languages l Everything is an object l Every object belongs to a class l Every class inherits from the class Object l Class variables of an object are instance variables of its class

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 42 Reflective definition of Class

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 43 Summary l The object paradigm Notion of object – viewpoints Classification – object extensions l Comparing Smalltalk, Eiffel, C++ and Java Criteria – libraries, environments, language characteristics Comparison – language characteristics l Design dimensions of object-oriented languages Object-oriented Orthogonal dimensions Open systems l Prototypes Prototypes – cloning and delegation Performance – dynamic compilation l Meta-level architectures Class Meta architecture Reflection

Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 44 Summary l The object paradigm Notion of object – viewpoints Classification – object extensions l Comparing Smalltalk, Eiffel, C++ and Java Tradeoffs between pure and hybrid languages Flexibility versus performance l Design dimensions of object-oriented languages Object-oriented = objects + classes + inheritance Orthogonal dimensions: objects, types, delegation, abstraction Open systems are systems that can be easily modified and extended Classless languages use cloning and delegation instead of instantiation and inheritance