CPT 140 Programming Constructs1 OBJECT ORIENTED TECHNOLOGY Terminology and Basic Concepts
CPT 140 Programming Constructs2 OBJECTIVES n Discuss the history of Object Oriented Technology (OT) n Describe basic concepts of OT n Define terms in Object Oriented Analysis & Design (OAD) and Programming (OOP) n Relate definitions to real-world examples n Mention some benefits of OT
CPT 140 Programming Constructs3 HISTORY OF OT n 1969 n Dr. Kristin Nygaard of Norway n Model fjord and movement of ships passing through it
CPT 140 Programming Constructs4 HISTORY OF OT n The Problem ä structured programming separates data from procedures n The Solution ä Object Oriented Programming ä model each component (data and procedure) as a single unit ä model relationships between components
CPT 140 Programming Constructs5 OT BASIC CONCEPTS n Objects and Classes n Operations n Requests n Attributes n Inheritance n Encapsulation n Polymorphism
CPT 140 Programming Constructs6 WHAT’S AN OBJECT? n Anything, real or abstract, about which we store data n Dr. Nygaard’s objects ä mathematical models of boats ä physical aspects of the fjord being analyzed n Other Examples ä an invoice, an organization, a screen with which a user interacts, a drawing, an airplane, an order-filling process...
CPT 140 Programming Constructs7 WHAT’S AN OPERATION? n An activity that reads or manipulates data of an object n Dr. Nygaard’s operations ä boats float, sink, move etc. n Other Examples ä calculating a total, checking a balance, adding a new employee, changing an address, deleting a customer...
CPT 140 Programming Constructs8 HOW OBJECTS COMMUNICATE n An object is sent a message, which in turn causes an operation to be invoked n Sometimes the operation returns a response
CPT 140 Programming Constructs9 WHAT’S AN ATTRIBUTE? n Characteristics that add detail to an object n Dr. Nygaard’s attributes ä color, weight, size, etc. n Other Examples ä someone’s name or address, an employee’s title, a book’s author, a part number, a room’s dimensions
CPT 140 Programming Constructs10 INHERITING ATTRIBUTES n Objects can be decomposed into other objects n Generalization hierarchy n Supertype versus subtype n An object inherits the attributes in its parent class
CPT 140 Programming Constructs11 SAMPLE GENERALIZATION HIERARCHY
CPT 140 Programming Constructs12 OBJECT ORIENTED ANALYSIS & DESIGN (OAD) n The steps Ê Find Classes and Objects Ë Define Attributes Ì Define Services n Confused? Welcome to the OO Paradigm!
CPT 140 Programming Constructs13 WHAT ARE CLASSES OF OBJECTS? n An object type or object class is a category of an object that has similar characteristics and behavior n Examples ä employee or student n Aha! ä An object type is found in the generalization hierarchy
CPT 140 Programming Constructs14 OBJECT INSTANCES n An object instance is an example of an object type n Examples ä John P. Smith, Invoice #12356 n And just to make it all really confusing, object instances are sometimes called objects!
CPT 140 Programming Constructs15 OBJECT ORIENTED PROGRAMMING (OOP) n More synonyms: ä operations are called methods ä messages are called requests or events n An event contains the object name, the method, and maybe a group of parameters n Once an object receives an event, it runs a script (program) that may modify its state or send messages to other objects
CPT 140 Programming Constructs16 ENCAPSULATION n The process of making implementation details of an object transparent to a user n Packaging data and operations together n Also called information hiding n The black box
CPT 140 Programming Constructs17 POLY-WHAT? n Polymorphism ä allows an instruction to be given to an object in the form of a generalized, rather than specific, detailed command ä while specific actions would be different, results are the same
CPT 140 Programming Constructs18 COMPARING SYNONYMS
CPT 140 Programming Constructs19 SOME BENEFITS OF OT n Reusability ä classes can be reused or inherited n Stability ä over time, classes become more stable n Easier Design ä black box concept n Faster Design ä create applications from existing components
CPT 140 Programming Constructs20 SUMMARY BY EXAMPLE n A VCR IS an object n A Sony VCR is an object type n Serial #9234 of Sony VCR is an object instance n Playback, record, and audio dubbing are examples of VCR operations n The concept that the VCR contains complex components you assume work is encapsulation n When you use a remote control, you are sending requests to the VCR