1 / 36

Illinois Institute of Technology

Illinois Institute of Technology. CS487 - Software Engineering Object -Oriented Concepts & Principle - Chapt 19 David A. Lash. Object Oriented Concepts & Principles. Object-Oriented Viewpoint - Characterize the problem domain as a set of objects with specific attributes and behaviors

emmly
Download Presentation

Illinois Institute of Technology

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. Illinois Institute of Technology CS487 - Software Engineering Object -Oriented Concepts & Principle - Chapt 19 David A. Lash

  2. Object Oriented Concepts & Principles • Object-Oriented Viewpoint - Characterize the problem domain as a set of objects with specific attributes and behaviors • Functions and methods manipulate the objects • Further characterize the objects into classes and subclasses • Leads to libraries of reusable classes and objects. • Reduces time to develop & higher quality programs • Easier to change

  3. Object Approach • Was software development only but now encompasses a complete SE view • More than OOP (OO programming), should consider OORA (OO Req Analysis) OO D (design) & OO CASE. • Engineering paradigm is more evolutionary since reuse of classes to emphasize

  4. Object Approach • The OO development process starts with requirements. • Would define requirement classes • During engineering and construction & release would follow the path below: From Requirements, then planning & Risk Analysis Identify candidate classes On to customer evaluation Save new classes Search class library Build classes unavailable

  5. What is an object? • A tangible and/or visible thing • Customer, Part, etc. • Something that may be apprehended intellectually • Appointment, Task, etc. • Something toward which thought or action is directed • Order, Process, etc.

  6. Object Definition An object is characterized by a number of operations and a state which remembers the effect of operations.

  7. What are an object’s characteristics? • Identity. • A way to distinguish between occurrences • Behavior. • How the object acts and reacts in terms of state changes and messages (methods) • State. • The state of an object encompasses all of the (usually static) properties of the object plus the current (usually dynamic) values of each of these properties

  8. Example OO Concepts - Classes, Objects & Inheritance • Assume have defined a class called Furniture and • within that class there is an object called chair Class: Furniture -------------------- Attributes: - Cost - Dimension - Location - Color Object: Chair -------------------- Attributes: - Cost - Dimension - Location - Color Inheritance

  9. Example OO Concepts - Operations & more Inheritance • Operations modify 1 or more attributes • E.g., location might be a function of building, floor & room. Then move might modify 1 or more of building, floor & room to effect location. Class: Furniture -------------------- Attributes: - Cost - Dimension - Location - Color Operations - Buy - Sell - Weigh - Move Object: Chair -------------------- Attributes: - Cost - Dimension - Location - Color Operations - Buy - Sell - Weigh - Move Inheritance

  10. Major Elements Classes & Objects Abstraction Encapsulation Hierarchy/Inheritance Polymorphism Principles of Object Orientation

  11. What is a class? • A class represents a template for several objects and describes how these objects are structured internally. Objects of the same class have the same definition both for their operations and for their information structures. • A.K.A an object type

  12. What is the instance of a class? • An instance is an object created from a class. The class describes the (behavior and information) structure of the instance, while the current state of the instance is defined by the operations performed on the instance.

  13. Instance of Tom from Persons Class of persons

  14. Classes & Objects • An OO concept that encapsulates the data and procedures needed to describe the content and behavior of some real work entity • Attributes that describe the class are walled off by methods that manipulate the data some way • the class encapsulates the data • the processing use methods to manipulate data • achieves information hiding & minimizes ripple effect.

  15. More On Classes & Objects • Classes also are generalized description that describe a category of objects (AKA template) • All objects within a class inherent its attributes, and operations • A superclass is a collection of classes and subclass is a specialize instance of the class Furniture Chair Table Desk Chair Instances

  16. Messages & Classes • OO = objects + classification + inheritance = communication • Messages are means by which objects interact • Provide stimulators to some behavior between objects • message[dest, operation, parms] Object: XXX -------------------- Attributes: - X1 - Y1 Operations - Z1 - A1 Object: AAA -------------------- Attributes: - A2 - B2 Operations - X2 - Y2 Msg(dest, oper, parm) Msg(dest, oper, parm)

  17. Encapsulation • Grouping related information together and protecting it from the outside world. (e.g., its structure and behavior) • E.g., grouping data (variables) and actions (methods) to form objects. Advantages: • Internal details of data & procedures hidden (reduces side effects of errors) • Classes contain templates of data structures & operations factilitating reuse • Interfaces are encapsulated via messages with details. (tends to reduce coupling).

  18. Hierarchy & Inheritance • Inheritance - A key difference between OO systems and conventional programming • Subclass Y inherits all attributes & operations. • All algorithms & data structures immediately available for reuse. • All changes and additions of the superclass are immediately available to the subclasses. (change propagation) Class: Furniture -------------------- Attributes: - Cost - Dimension - Location - Color Operations - Buy - Sell - Weigh - Move Class: Kitchen_furniture -------------------- Attributes: - Cost - Dimension - Location - Color Operations - Buy - Sell - Weigh - Move Inheritance

  19. More On Hierarchy & Inheritance • New attributes and operations can be added at each level of the hierarchy • When adding a class have several options • Class can be designed from scratch • Search class hierarchy to find one similar to inherit from • Can restructure the class hierarchy to enable inheritance by the new class • Can override characteristics of a superclass and rewrite them for current class use.

  20. Hierarchy & Multiple Inheritance Class: X1 -------------------- Attributes: - Char1 - Char2 - Char3 +char4 +char5 Suppose wanted X1 to inherit Chart1, 2, 3, 4, 8 Class: X2 -------------------- Attributes: - Char1 - Char2 - Char3 - Char4 - Char5 +char6 +Char7 Class: X3 -------------------- Attributes: - Char1 - Char2 - Char3 - Char4 - Char5 - Char6 Class: X4 -------------------- Attributes: - Char1 - Char2 - Char3 - Char4 - Char5

  21. Hierarchy & Inheritance Suppose wanted X1 to inherit Chart1, 2, 3, 4, 8 Class: X1 -------------------- Attributes: - Char1 - Char2 - Char3 Class: X1 -------------------- Attributes: - Char1 - Char2 - Char3 +char4 +char5 +char4 Class: X2 -------------------- Attributes: - Char1 - Char2 - Char3 - Char4 - Char5 Class: X2 -------------------- Attributes: - Char1 - Char2 - Char3 - Char4 +char6 +Char7 +char5 Class: X3 -------------------- Attributes: - Char1 - Char2 - Char3 - Char4 - Char5 - Char6 Class: X4 -------------------- Attributes: - Char1 - Char2 - Char3 - Char4 - Char5 Class: X2a -------------------- Attributes: - Char1 - Char2 - Char3 - Char4 - Char5 Class: X2b -------------------- Attributes: - Char1 - Char2 - Char3 - Char4 - Char8

  22. Hierarchy & Inheritance Suppose added classes benglishcar & englishmotorcycle Both need operations leakOil() & eltronicFailure() Class: Vehicle Different parts of hierarchy? Restructure hierarchy? Copy code method in each? Class: EnginePoweredVehicle Class: PersonPoweredVehicle Multi-inheritence generally not allowed Class: 2wheeledVehicle Class: 4wheeledVehicle enginlishthing Class: car Class: Motorcycle EnglishMotorcyle EnglishCar

  23. Single Inheritance w/ Java • Java handles single inheritance problem by: • creating a separate hierarchy with mixed behavior classes called an interface hierarchy. • When you create a new class you canpick from the superclass also from the other hierarchy. • The interface hierarchy is a collection of methods (or behaviors), definitions and constants. (E.g., mathematical functions)

  24. Polymorphism • A facility for the same method name to be used with different objects. • Suppose had 4 graphical shapes and wanted to enable them to grow in size on the screen. • Set all shapes to be subclasses of a general class called shape. • Each object provides a grow method • Therefore can call shape.grow(size); • The run-time system invokes the version of grow from the object being used at the time. Circle circle; Oval oval; Rectangle rectangle; Triangle t; Circle.grow(change); oval.grow(change); rectangle(change); t.change(change);

  25. More On Objects • Objects tend to be • external entities - other systems, devices, people, • things - letters, reports, displays, • Events - sensor alert, robot movement • Roles - manager, engineer, salesperson • Organization unit - division, group, team • Places - loading dock, manufacturing floor • Structure - sensors, 4-wheeled vehicles that define categories of objects

  26. More On Objects - II • From the homesafe example • extract nouns from system description and create a list of potential objects Potential object/class General Class homeowner role or external entity sensor external entity control panel external entity installation occurrence system (AKA security sys) thing number, type attributes of sensor master password thing telephone number thing sensor event occurrence audible alarm external entity monitoring service external entity

  27. More On Objects - III • Six characteristics that should be used on each potential object: • Retained Information - information about it must be remembered • Needed services - have a set of identifiable operations that can change attribute’s value • Multiple Attributes - Are the attributes “major” and useful? • Common Attributes - can define a set that apply to all occurrences of object • Essential requirements - External entity in problem and produces information essential to solution

  28. More On Objects - IV • Apply criteria to potential objects Potential object/class General Class homeowner Fail 1,2, fail 6 OK sensor OK: All OK control panel OK: all OK installation Rejected system (AKA security sys) OK: all OK number, type Fail: 3 fails master password Fail: 3 fails telephone number Fail: 3 fails sensor event OK: All OK audible alarm Ok 2-6 OK monitoring service Fail: 1-2 fail 6 OK

  29. More On Attributes • They describe the object and define & clarify it. • E.g., player - couple have • name, position, batting aver, games played • name, average salary, peak salary, years left on contract • Study narrative and identify & select things reasonably belong to object • Data items needed to define object in problem • Security system has set of attributes allow to configure • sensor_info = sensor_type + sensor_numb + alarm_threshold • Alarm_response_info = delay_time + phone_numb _ alarm_type • activation/deact_info = master_passwd + number_of_tries + temp_passwd

  30. More On Operations • Define define the behavior of an object & change the attributes some way • manipulate data in some way (add, delete, change) • performance computation • monitor occurrence of an event

  31. More On Operations - II • Study narrative and identify reasonably belong to object • study the “verbs” of narrative • “Sensor is assigned a number & type” • “Master passwd is programmed for arming & disarming ...” • Tells us, • assign operation for sensor object • program operation for system object • arm/disarm -> system (maybe system_status = armed | disarmed)

  32. More On Operations - III • Would also consider the communication between objects: • What know activities occur during the life of the object? • Communication between objects -> clues • sensor event - message -> sensor to display location and number • cntl panel -> send -> system a reset message to update system status • audible alarm sent query message

  33. More On Operations Object: System -------------------- Attributes: -SystemID - phone number - system status - sensor table sensor type sensor number alarm threshold - alarm display time - telephone number - alarm threshold - master passwor - temporary password - number of tries ---------------------- Operations: program - display - Reset - query - modify - call

  34. Object-Oriented Programming Object-oriented programming is a method of implementation in which - programs are organized as cooperative collections of objects, - each of which represents an instance of some class, - and whose classes are all members of a hierarchy of classes united via inheritance relationships.

  35. Object-Oriented Analysis Object-oriented analysis is a method of analysis that • examines requirements form the perspective of the classes and objects found in the vocabulary of the problem domain.

  36. Object-Oriented Design Object-oriented design is a method of design • encompassing the process of object-oriented decomposition and • a notation for depicting both logical and physical as well as • static and dynamic models of the system under design.

More Related