Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object-Oriented Principles and Implementations

Similar presentations


Presentation on theme: "Object-Oriented Principles and Implementations"— Presentation transcript:

1 Object-Oriented Principles and Implementations

2 Agenda Evolution of software OO software elements Object instantiation
Run-time environment Mapping to real-world Object lifecycle

3 Evolution of Software Remember: form, function, style Paradigms
data, logic, paradigm state, behavior, style state: collection of all data values (e.g., at this time) Paradigms monolithic modular functional => ADTs => OO => componentware??

4 OO Software Elements: Objects
real life view: person, place, thing, concept, event OO view: instantiation of a class storage view: area of storage allocated to hold both the data for this object and its superclasses (its “state”), including all hidden data, and references to executable code the object can invoke/call multiple objects of same class share executable code and static variables

5 OO Software Elements: Classes
real life view: template, factory, pattern, IRS tax form OO view: abstraction of a kind of object definition of services (methods) that can be performed storage view: one copy of all static variables per class, plus the storage to hold one copy of all method code, plus some overhead no storage for object/instance state

6 Local Object Instantiation
two storage areas: local reference to object local storage for object’s state and methods “new” is normally used allocates local memory object storage is released when: object is no longer in use and garbage collector runs program exits

7 Local Object Storage Temperature Class
Declaration: Temperature outside_temp; Temperature Class outside_temp (2AF0) (object reference is null) private double fahr_value; Storage allocation: outside_temp = new Temperature(32.0); public Temperature(double temp) {fahr_value = temp;} 2AF0 3C320 Temperature() code 3C000 f_to_c() code 3C200 public static double f_to_c(double temp) {return 9/5*(temp-32.0);} getCelsius() code 3C300 3C320 32.0 public double getCelsius() {return f_to_c(fahr_value);} 3C328 3C000 3C32C 3C200 3C330 3C300

8 Two Local Objects of Same Class
Temperature outside_temp = new Temperature(32.0); Temperature water_temp = new Temperature(212.0); 2AF0 3C320 3C320 32.0 Temperature() code 3C000 2AF4 3C340 3C328 3C000 f_to_c() code 3C200 3C32C 3C200 getCelsius() code 3C300 3C330 3C300 3C340 212.0 3C348 3C000 3C34C 3C200 3C350 3C300

9 Shallow Object Copy Temperature outside_temp = new Temperature(32.0);
Temperature water_temp = new Temperature(212.0); Temperature a_temp = outside_temp; 2AF0 3C320 3C320 32.0 Temperature() code 3C000 2AF4 3C340 3C328 3C000 f_to_c() code 3C200 2AF8 3C320 3C32C 3C200 getCelsius() code 3C300 3C330 3C300 3C340 212.0 3C348 3C000 3C34C 3C200 3C350 3C300

10 Remote Object Instantiation
four storage areas: local reference to object (actually, for “stub”/proxy) local storage for proxy and parameters remote storage for remote proxy, parameters and return value/exception info remote storage for object’s state and methods “new” is not used remote proxy causes “new” for remote object foundation for most of EA infrastructure

11 Run-Time Environment loads/unloads classes schedules threads
allocates storage runs garbage collection interfaces with operating system

12 Mapping to Real World enabled by from exposed state to exposed interface handling large problems: desirable characteristics object-orientation’s part in solving problems

13 Desirable Characteristics: Modularity
isolates functionality serves as unit of decomposition can be assigned as a work item allows for a standard interface speeds time to market by aiding problem partitioning helps with understandability thus maintainability and extensibility

14 Desirable Characteristics: Encapsulation
simplifies interface promotes consistency controls access allows underlying data representation to change aids maintainability

15 Desirable Characteristics: Abstraction
allows easier identification of reusable parts saves work effort by closer mapping to problem improves reliability by supporting reuse makes changes easier to propagate central, inherited concepts saves development time by inheriting capability

16 Desirable Characteristics: Reuse
saves time allows for purchase vs. roll-your-own allows reaping benefits of accumulated experience from reused entity

17 Object Orientation and the Real World
Classes are generalizations and abstractions of real-world objects and their behaviors examples: business concepts (Order), people (User), service provider (DatabaseInterface) Objects are unique and have an identity examples: order[451] (instance of Order) SaleClerk[“Jane Doe”] (instance of User) inventory_db (instance of DatabaseInterface)

18 Bean Object Activation Activities
creation create bean object but defer assigning storage for state passivation disassociate bean object from its state and save the state removes bean object from memory activation loads bean object into memory restores state and associates with bean object removal remove bean object from memory


Download ppt "Object-Oriented Principles and Implementations"

Similar presentations


Ads by Google