1 / 18

Object-Oriented Principles and Implementations

Explore the evolution of software and the key elements of object-oriented programming, including object instantiation, the runtime environment, mapping to the real world, and the object lifecycle.

bsuzanne
Download Presentation

Object-Oriented Principles and Implementations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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

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

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

  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

More Related