350 likes | 516 Views
OBJECT ORIENTED MODELING, CONCEPTS AND PRINCIPLES. Chapter 20. What is OO Development ?. “New” way of thinking about problems using models organized around real world concepts. The fundamental construct is the object
E N D
OBJECT ORIENTED MODELING, CONCEPTS AND PRINCIPLES Chapter 20 February 14, 1999 R. A. Volz
What is OO Development ? • “New” way of thinking about problems using models organized around real world concepts. • The fundamental construct is the object • Combines both data structure and operations in a single entity called an object. • Leads to reuse, faster software development and higher quality programs. • Easier to maintain • Structure inherently decoupled • Fewer side-effects February 14, 1999 R. A. Volz
Object Oriented Concepts • Objects and Object Model • Object: Data and operations relevant to some real world or significant program entity encapsulated into a monolithic unit accessible only through a well defined interface. For ex. File in the file system together with operations such as open, close, read, & write, • Object Model: Describes the structure of the objects in the system • their identity, relationships to other objects, attributes and operations. February 14, 1999 R. A. Volz
Object Modeling • Classification & Classes • A classdescribes a group of objects with similar properties (attributes), common behavior (operations), common relationships to other objects, and common semantics. February 14, 1999 R. A. Volz
Class Name Attributes Operations Object Classes • Thus, a class is an abstraction that describes relevant properties and hides the rest. Represented diagrammatically as below. February 14, 1999 R. A. Volz
Object Modeling February 14, 1999 R. A. Volz
Object Modeling • Attributes: An attributeis a data value held by the objects in a class. Name, age, and weight are attributes of Person objects. February 14, 1999 R. A. Volz
Object Modeling • Operations and Methods : • Operations : An operation is a function or transformation that may be applied to or by objects in a class. Each operation has a target object as an implicit argument. The behavior of the operation depends on the class of its target. • Methods : A method is the implementation of an operation for a class. • Categories: 1) manipulate data, 2) perform computation, and 3) monitor for occurrence of controlling event. February 14, 1999 R. A. Volz
Object Modeling • An operation may have arguments in addition to its target object. Such arguments parameterize the operation but do not affect the choice of method. February 14, 1999 R. A. Volz
Polygon Vertices Border Color Fill Color Draw Erase Move Class and Instance Polygon v={(0,0),(0,1),(1,0)} BC = Red FC = Blue Draw Erase Move February 14, 1999 R. A. Volz
Abstraction and Encapsulation February 14, 1999 R. A. Volz
Abstraction and Encapsulation • Abstraction • Isolate those aspects that are important and suppress (or hide) those that are unimportant (e.g., representations). • Focus on what object is and does before deciding how it should be implemented. • Abstraction allows dealing only with application domain concepts, not making design and implementation decision before problem is understood. February 14, 1999 R. A. Volz
Abstraction and Encapsulation • Encapsulation (Information Hiding) • Separates the external aspects of an object, which are accessible to other objects, from the internal implementation details of the object, which are hidden from other objects. • Combining Data and Operations: • The OO approach combines the data structure and operations in a single entity. February 14, 1999 R. A. Volz
<<Interface>> Class Name Operations Interfaces • Does not have an implementation of its own. • Other classes provide implementations of it. • Client classes are only interested in behavior. February 14, 1999 R. A. Volz
Inheritance • Sharing of attributes and operations among classes based on hierarchical relationship. February 14, 1999 R. A. Volz
Polygon Vertices Border Color Fill Color Draw Erase Move Right Triangle Vertices Hypotenuse length Border Color Fill Color Draw Erase Move • • Class and Subclass February 14, 1999 R. A. Volz
Operations • Polymorphism • The same “operation” may behave differently on different classes. E.g., the move operation behaves differently on a Window and ChessPiece. • Operations may be overloaded when subclasses defined. • The compiler can distinguish based on the type of the operands in method invocations which operation is actually needed. February 14, 1999 R. A. Volz
Car Paint Polygon Paint Triangle Paint Square Paint Polymorphism February 14, 1999 R. A. Volz
Communication • Message: [destination, operation, params] February 14, 1999 R. A. Volz
What Does OO Mean? • Pressman (Coad & Yourdon) • Objects (identity) • Classification • Inheritance • Communication • Rumbaugh • Objects (identity) • Classification • Inheritance • Polymorphism February 14, 1999 R. A. Volz
Object Modeling Technique • Object modeling technique (OMT) extends from analysis thru design to implementation • Analysis model contains objects found in the application domain, including properties of object and their operations. • These application domain objects form a framework to the design model. February 14, 1999 R. A. Volz
Object Modeling Technique • The same seamless notation is used from analysis to design to implementation. • The system is modeled using three related but different view points. • Object Model : Represents the static, structural, “data” aspects of the system. • Dynamic Model : Represents the temporal, behavioral, “control” aspects of the system. • Functional Model : Represents transformational, “functional” aspects of the system. February 14, 1999 R. A. Volz
Object Modeling • Links and Associations • Link: A physical or conceptual connection between instances. E.g., Joe Smith Works-for Simplex company. Mathematically, a tuple, i.e., an ordered list of object instances. A link is an instance of an association. • Associations : A group of links with common structure and semantics. E.g., a person Worksfor a company. All the links in an association connect objects from the same classes. February 14, 1999 R. A. Volz
Object Modeling • Multiplicity: • Specifies how many instances of one class may relate to a single instance of an associated class • Role Names: • One end of an association. Binary association has two roles. • Link attributes • May be defined for associations, e.g., if the association is “uses,” the link attribute might be one of permission. February 14, 1999 R. A. Volz
Binary Association & Multiplicity February 14, 1999 R. A. Volz
Ternary Association February 14, 1999 R. A. Volz
Link Associations February 14, 1999 R. A. Volz
Aggregation • A “part-whole” or “a-part-of” relationship February 14, 1999 R. A. Volz
Easier to maintain Combines data structure and behavior in a single entity Emphasizes object structure Reuse more readily accomplished Harder to maintain May separate data and behavior Emphasizes procedural structure Reuse limited, hence possible delay in software construction Object-Oriented vs Structured Approach February 14, 1999 R. A. Volz
Strong cohesion and weak coupling Encapsulation, Inheritance and Polymorphism are strong features of OO software development Harder to achieve weak Coupling and strong cohesion Some languages support encapsulation and polymorphism, but rarely inheritance Object-Oriented vs Structured Approach February 14, 1999 R. A. Volz