DOC PREVIEW
UT Dallas CS 4337 - #Sebesta ch12 oop - shorter to use

This preview shows page 1-2-3-4-24-25-26-50-51-52-53 out of 53 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Chapter 12Chapter 12 TopicsIntroductionObject-Oriented ProgrammingInheritanceObject-Oriented ConceptsObject-Oriented Concepts (continued)Slide 8Slide 9Slide 10Dynamic BindingDynamic Binding Conce (Abstract Class, Virtual Method, …)Design Issues for OOP LanguagesThe Exclusivity of ObjectsAre Subclasses Subtypes?Single and Multiple InheritanceAllocation and DeAllocation of ObjectsDynamic and Static BindingNested ClassesInitialization of ObjectsSupport for OOP in SmalltalkSupport for OOP in Smalltalk (continued)Slide 23Slide 24smalltalkSlide 26Support for OOP in C++Support for OOP in C++ (continued)Slide 29Inheritance Example in C++Re-exportation in C++Reexportation (continued)Slide 33Slide 34Support for OOP in C++ … virtualSlide 36Support for OOP in JavaSupport for OOP in Java (continued)Slide 39Slide 40Slide 41Implementing OO ConstructsInstance Data StorageDynamic Binding of Methods CallsJava Class Instance Record (CIR) & vtableSlide 46C++ Class Instance Record (CIR)Slide 48SummaryC++ Access ControlSlide 51Java – Access ControlJava – InheritanceChapter 12Support forObject-Oriented ProgrammingCopyright © 2012 Addison-Wesley. All rights reserved. 1-2Chapter 12 Topics•Introduction•Object-Oriented Programming•Design Issues for Object-Oriented Languages•Support for Object-Oriented Programming in C++•Support for Object-Oriented Programming in Java•Implementation of Object-Oriented ConstructsCopyright © 2012 Addison-Wesley. All rights reserved. 1-3Introduction•Many object-oriented programming (OOP) languages–Some support procedural and data-oriented programming (e.g., Ada 95+ and C++)–Some support functional program (e.g., CLOS)–Newer languages do not support other paradigms but use their imperative structures (e.g., Java and C#)–Some are pure OOP language (e.g., Smalltalk & Ruby)–Some functional languages support OOP, but they are not discussed in this chapterCopyright © 2012 Addison-Wesley. All rights reserved. 1-4Object-Oriented Programming•Three major language features:–Abstract data types (Chapter 11)–Inheritance•Inheritance is the central theme in OOP and languages that support it–PolymorphismCopyright © 2012 Addison-Wesley. All rights reserved. 1-5Inheritance•Productivity increases can come from reuse–ADTs are difficult to reuse—always need changes–All ADTs are independent and at the same level•Inheritance allows new classes defined in terms of existing ones, i.e., by allowing them to inherit common parts•Inheritance addresses both of the above concerns--reuse ADTs after minor changes and define classes in a hierarchyCopyright © 2012 Addison-Wesley. All rights reserved. 1-6Object-Oriented Concepts•ADTs are usually called classes•Class instances are called objects•A class that inherits is a derived class or a subclass•The class from which another class inherits is a parent class or superclass•Subprograms that define operations on objects are called methodsCopyright © 2012 Addison-Wesley. All rights reserved. 1-7Object-Oriented Concepts (continued)•Calls to methods are called messages•The entire collection of methods of an object is called its message protocol or message interface•Messages have two parts--a method name and the destination object•In the simplest case, a class inherits all of the entities of its parentCopyright © 2012 Addison-Wesley. All rights reserved. 1-8Object-Oriented Concepts (continued)•Inheritance can be complicated by access controls to encapsulated entities–A class can hide entities from its subclasses–A class can hide entities from its clients–A class can also hide entities for its clients while allowing its subclasses to see them•Besides inheriting methods as is, a class can modify an inherited method–The new one overrides the inherited one–The method in the parent is overridenObject-Oriented Concepts (continued)Three ways a class can differ from its parent:1. The parent class can define some of its variables or methods to have private access, which means they will not be visible in the subclass2. The subclass can add variables and/or methods to those inherited from the parent3. The subclass can modify the behavior of one or more of its inherited methods.Copyright © 2012 Addison-Wesley. All rights reserved. 1-9Copyright © 2012 Addison-Wesley. All rights reserved. 1-10Object-Oriented Concepts (continued)•There are two kinds of variables in a class:–Class variables - one/class–Instance variables - one/object•There are two kinds of methods in a class:–Class methods – accept messages to the class–Instance methods – accept messages to objects•Single vs. Multiple Inheritance•One disadvantage of inheritance for reuse: –Creates interdependencies among classes that complicate maintenanceCopyright © 2012 Addison-Wesley. All rights reserved. 1-11Dynamic Binding•Polymorphic Variables–A polymorphic variable can be defined in a class that is able to reference (or point to) objects of the class and objects of any of its descendants•For the Overriding Methods–When a class hierarchy includes classes that override methods and such methods are called through a polymorphic variable, and the binding to the correct method will be dynamic•These features allow software systems to be more easily extended during both development and maintenanceCopyright © 2012 Addison-Wesley. All rights reserved. 1-12Dynamic Binding Conce(Abstract Class, Virtual Method, …)•An abstract method is one that does not include a definition (it only defines a protocol)•An abstract class is one that includes at least one virtual method•An abstract class cannot be instantiatedCopyright © 2012 Addison-Wesley. All rights reserved. 1-13Design Issues for OOP Languages•The Exclusivity of Objects (pure OOP or not)•Are Subclasses Subtypes? (is-a relationship)•Single vs Multiple Inheritance•Object Allocation and Deallocation•Dynamic vs Static Binding•Nested Classes or not•Initialization of ObjectsCopyright © 2012 Addison-Wesley. All rights reserved. 1-14The Exclusivity of Objects•Everything is an object–Advantage - elegance and purity–Disadvantage - slow operations on simple objects•Add objects to a complete typing system–Advantage - fast operations on simple objects–Disadvantage - results in a confusing type system (two kinds of entities)•Include an imperative-style typing system for primitives but make everything else objects–Advantage -


View Full Document

UT Dallas CS 4337 - #Sebesta ch12 oop - shorter to use

Download #Sebesta ch12 oop - shorter to use
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view #Sebesta ch12 oop - shorter to use and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view #Sebesta ch12 oop - shorter to use 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?