130 likes | 269 Views
OO Technology. Low semantic Gap Easy to Understand Modification tends to be local (to Object). Object. An Object is characterized by a number of operations and a state which remembers the effect of these operations. (Fig 3.2, 3.3)
E N D
OO Technology • Low semantic Gap • Easy to Understand • Modification tends to be local (to Object)
Object • An Object is characterized by a number of operations and a state which remembers the effect of these operations. (Fig 3.2, 3.3) • A model consists of many objects with Static (stable over time) relations and dynamic relations by which objects actually communicate with each other. • Fig 3.4 shows how an object is composed from parts • Another method of joining parts together is partition hierarchy method (Fig 3.5) • Since the grouping has to represented by another object (Family), that method can be classified aggregation.
Object (cont.) • Fig 3.6 shows the attributes of an object • Dynamics in OO models are created by objects sending stimuli to one another (Fig 3.7) • Complex behavior (Fig 3.8) • Encapsulation - ensures that only objects operations affect it • Information Hiding is also supported
Class and instance • A class represents a template for several objects and describes how these objects are structured internally. Objects of the same class have the same definitions both for their operati0onsand for their information structures (Fig. 3.9 - 3.13) • An instance is an object created from the class. The class describes the structure of the instance, while the current state of the instance is defined by the operations performed on the instance • Different instances can be manipulated by different sequences of operations and, as a result, have different internal states.
Polymorphism • Means that the sender of a stimulus does not need to know the receiving instance’s class. The receiving instance can belong to any arbitrary class. • Often polymorphism is said to mean that one operation can be implemented in different ways in different classes (this is actually the consequence of polymorphism) • Dynamic binding - a stimulus is not bound to the operations in the receiving instance’s class until it is sent. • Limited polymorphism - restricted the instances with which can be associated • The receiver determines how the stimulus will be interpreted
Inheritance • Fig 3.14 • it is the core idea for reuse • helps in easy modifications • avoids redundancy • we can generalize or specialize classes using inheritance • descendants/subclass, ancestors-superclass, descendants subclass, direct descendants - child, direct ancestors - parent • Abstract and concrete classes • 3.16 different ways to inherit
Adding a new class • To go up in the hierarchy to see if the ancestors are more suitable inheritance • describe the class from the beginning • restructure the inheritance hierarchy (3.17) • redefine the characteristics that we want to change (overriding)
Why Inheritance • Reuse through abstract classes and class libraries • Sub-typing to create behaviorally compatible subclasses with no restriction • Specialization - the descendant is no longer behaviorally compatible with its parent (e.g., .3.18 Adult and Person) • Conceptual - corresponds to intuitive semantic - a dog is a mammal • Avoid Spaghetti inheritance • multiple inheritance (Houseboat) - Fig 3.19, 3.20
OO systems development • Entropy - a closed systems disorder cannot be reduced • A program that is used will be modified • modification increases complexity ( normally) • design systems with low entropy (4.1) • Systems development methods (4.2 - 4.4)
Function/data methods • Fig 4.5 • OO focuses on what has to be done , Funct/data focusses on how a process has to be done • Problems with Function/data • instability due to modification • larger semantic gap • Table 4.1
Object Oriented analysis • Finding the objects • passive object containing persistent information should not be dependent on objects that deal with the interface (since they change) • Organize the objects, objects can be grouped as active/passive, physical/conceptual etc. • Object interaction • operations on objects - through interface • Object implementation - u can separate ones requiring more modifications
OO construction • The goal is that objects identified during the analysis should also be found within the design. We must have straightforward rules for transforming analysis model into design model and programming language (this is called traceability) • the objects can be implemented using previously implemented source code (components)
OO Testing • Less dramatic compared to Function/data model • must have knowledge of class interaction and test all relevant objects • redo the test data if you override some operations during modification • be aware of polymorphism while testing • Yoyo problem - sending stimuli to itself, you have to go up and down the hierarchy in order to understand the effect of a change