Objects - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Objects

Description:

type variable stored with the //ExampleClass object in heap ... Print Spooler. Network Services object. File System. Teaching Points ... – PowerPoint PPT presentation

Number of Views:18
Avg rating:3.0/5.0
Slides: 15
Provided by: elect77
Category:
Tags: objects | spooler

less

Transcript and Presenter's Notes

Title: Objects


1
Objects
  • Lecture OO04
  • Representing Objects

2
References
  • Ambler, S., The Object Primer, Cambridge Univ.
    Press, 2001, Chapter 1 2, Sections 5.1 - 5.5

3
Teaching Points
  • Review of program memory organization
  • Introduction to object constructors
  • Investigation of object characteristics
  • Singleton Pattern

4
Review
  • Vehicle example?
  • Memory storage types

5
Collaboration Diagrams (Objects)
  • A type of Interaction Diagram
  • Objects
  • name
  • type

6
Object Characteristics
  • State
  • Behavior
  • Identity

7
State
  • where in memory do objects go
  • different constructor invocations
  • destructor invocations

8
Memory storage types
  • Static Memory
  • global variables
  • static class members
  • static function variables
  • Automatic Memory (Stack)
  • local variables
  • function parameters
  • Free Store (Heap)
  • memory explicitly requested by programmer

9
class ExampleClass int i //prim. type
variable stored with the //ExampleClass object
in heap AnotherClass handleName //handle
stored with ExampleClass object //note no
object exists AnotherClass yet static int
j //primitive type var. in static
memory //note one copy used for the whole
class static AnotherClass anotherName //handle
is stored in static mem //note no object
exists yet static anotherName new
AnotherClass() //new object is stored on the
heap //all instances use this single object
public ExampleClass handleName new
AnotherClass() //new object is stored on the
heap //each instance creates its own object
public someFunction() int i //prim.
type variable stored on the stack AnotherClass
someName new AnotherClass() //where??
10
Behavior
  • Objects accept messages
  • Message can be function calls
  • Modifier
  • Selector
  • Iterator
  • Constructor
  • Destructor

11
Identity
  • That property that distinguishes an object from
    all other objects
  • mixing addressing w/ identity
  • mixing data value with identity

12
Discussion
  • What about assignment?
  • What about parameter passing?
  • What about equivalence?
  • What about garbage collection?

13
Singleton Pattern
  • Print Spooler
  • Network Services object
  • File System

14
Teaching Points
  • Review of program memory organization
  • Introduction to object constructors
  • Investigation of object characteristics
  • Singleton Pattern
Write a Comment
User Comments (0)
About PowerShow.com