Docsity

Object oriented Modelling and Design Notes and Questions, Lecture notes of Object Oriented Analysis and Design

Partial preview of the text

Download Object oriented Modelling and Design Notes and Questions and more Lecture notes Object Oriented Analysis and Design in PDF only on Docsity!

OBJECT ORIENTED MODELING AND DESIGN

RT 701 2+1+

Module 1 Introduction: object oriented development-modeling concepts – object oriented methodology – models – object oriented themes-Object Modeling– links and associations – advanced links and association concepts – generalization and inheritance - grouping constructs – a sample object model Advanced Object Modeling: aggregation – abstract classes – generalization as extension and restriction – multiple inheritance – metadata – candidate keys – constraints.

Module 2 Dynamic modeling: Events and states – Operations – Nested state diagrams – Concurrency – Advanced dynamic modeling concepts – A sample dynamic model

  • Relationship of Object and Dynamic models. Functional modeling: Functional models – Data Flow Diagrams - Specifying operations – Constraints – A sample functional model – Relation of functional to Object and Dynamic models.

Module 3 Analysis: Analysis in object modeling, dynamic modeling and functional modeling, Adding operations- Iterating the analysis System Design: Breaking system into subsystems - Identifying concurrency- allocating subsystems to processors and tasks, managing of data stores. Handling of global resources- handling boundary conditions-Common Architectural Frameworks

Module 4 Object Design: Overview of Object design – Combining the three models – Designing algorithms – Design optimization – Implementation of control – Adjustment of inheritance - Design of association – Object representation – Physical packaging – Documenting design decisions-Comparison of methodologies

Module 5 Other Models: Booch‟s Methodology- Notations, models, concepts. Jacobson Methodology- architecture, actors and use-cases, requirement model, Analysis Model, Design model, Implementation model and Test Model-Unified Modeling Language (UML).

Text Book

  1. Object Oriented Modeling and Design -JamesRumbaugh, Prentice Hall India

Module 1 Introduction: object oriented development-modeling concepts – object oriented methodology – models – object oriented themes-Object Modeling– links and associations – advanced links and association concepts – generalization and inheritance - grouping constructs – a sample object model Advanced Object Modeling: aggregation – abstract classes – generalization as extension and restriction – multiple inheritance – metadata – candidate keys – constraints.

1 Introduction (i)Object Data can be quantized into discrete, distinguishable entities which are called objects. (ii) Object Oriented Approach means organizing software as a collection of discrete objects that incorporate both data structure and behavior. 2 Object Oriented Development is a new way of thinking about software based on abstractions that exist in the real world as well as in the program. 3 Object Oriented Methodology is a methodology for object oriented development and a graphical notation for representing objects oriented concepts. We can call this methodology as OMT. The methodology has the following stages:

  1. Analysis - An analysis model is a concise, precise abstraction of what the desired system must do, not how it will be done. It should not contain any implementation details. The objects in the model should be application domain concepts and not the computer implementation concepts.
  2. System design - The designer makes high level decisions about the overall architecture. In system design, the target system is organized as various subsystems based on both the analysis structure and the proposed architecture.
  3. Object design - The designer builds a design model based on the analysis model but containing implementation details. The focus of object design is the data structures and algorithms needed to implement each cycle.
  4. Implementation - The object classes and relationships developed during object design are finally translated into a particular programming language, database, or hardware implementation. During implementation, it is important to follow good software engineering practice so that the system can remain the traceability, flexibility and extensibility.

The OMT methodology uses three kinds of models Object Model-describes the static structure of the objects in a system and their relationships. This model mainly contains object diagrams. Dynamic Model-describes the aspects of a system that change over time. This model mainly contains state diagrams. Functional Model-describes the data value transformations within a system. This model contains the data flow diagrams 4 Object Oriented Themes : There are several themes in an object oriented technology. These themes are not unique to object oriented systems. We can see some important themes: Abstraction-Abstraction consists of focusing on the essential, inherent aspects of an entity and ignoring its accidental properties. In system development, it focuses only on what an object is and does, before deciding how it should be implemented. Encapsulation- It can also be called as information hiding. It consists of separating 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. It is not unique to object oriented languages. Combining Data and Behavior-The caller of an operation need not consider how many implementations of a given operation exist. Operator polymorphism shifts the burden of deciding what implementation to use from the calling code to the class hierarchy. As an example, let us talk about an object oriented program calling a draw procedure for drawing different figures say a polygon, circle, or text. The decision of which procedure to use is made by each object, based on its class. Sharing- Inheritance of both data structure and behavior allows a common structure and behavior allows common structure to be shared among several similar subclasses without redundancy. The sharing of code using inheritance is one of the main advantages of object oriented languages. (5) Object Modeling: A model is an abstraction of something for the purpose of understanding it before building it. It is easier to manipulate than the original entity. An object model captures the static structure of a system, relationships between the objects, and the attributes and operations that characterize each class of objects.

As the example above shows the symbol for an object instance, while that of class diagram is a rectangle. In the above example, JS, MS are instances of class Person. (d)Attributes: An attribute is a data value held by objects in a class. Eg: - In the above example, Name, age, etc.of a person are attributes. Attributes are listed in the second part of the class box. So in the above example,

Fig.2.2 Attributes and values

(e) Operations and methods: An operation is a function or transformation that may be applied to or by objects in a class. Operations are listed in the lower third of the class box. Eg: - consider the above example, change – job and change-address on Person class.

Fig.2.3 Operations

Each attribute name may be followed by operational details, list of attributes and list of operations. Each operation name may be followed by operational details such as operational details such as argument list and result type. 6 Links and associations: They are used for establishing relationships among objects and classes.

Link- A link is a physical or conceptual connection between object instances .We can say that a link is an instance of an association. Eg: - J S works for Simplex company. Association – Describes a group of links with common structure and common semantics‟:- A person works for a company. They are inherently bidirectional. It means that a binary association can be traversed in both directions. They are implemented as pointers. The below figure shows a 1-1 association and corresponding links.

Fig. 2.4 Class Diagram

Fig.2.5 Instance Diagram

Multiplicity – specifies how many instances of one class may relate to each instance of another class. The solid balls,”2+” are multiplicity symbols. Associations may be binary, ternary or higher order.

Fig.2.6 Ternary associations and links

Fig.2.9 Ordered sets in an association

iv) Qualification – Qualifier is a special attribute that reduces the effective multiplicity of an association. It reduces the effective multiplicity of an association. We can qualify a one to many and many to many association. For eg: - In the below figure a directory has many files .A file may only belong to a single directory. Within the context of a directory, the file name specifies a unique file .A file corresponds to a directory and a file name.

Fig.2.10 A qualified association

(v) Aggregation: Aggregation is the “part-whole” relationship in which objects representing the components of something are associated with an object representing the entire assembly. The figure shows a portion of an object model for a word processing. Here a document consists of many paragraphs, each of which consists of many sentences.

Fig. 2.11 Aggregation 8 Generalization and Inheritance : Generalization is the relationship between a class and one or more refined versions of it. The class being refined is called the „superclass‟ and each refined version are called a „subclass‟. For example, Equipment is the superclass of Pump and tank. Attributes and operations that are common to a group of subclasses are attached to the superclass and shared by each subclass. Generalization is

sometimes called a „is-a‟ relationship. Each instance of a subclass is an instance of the superclass. The notation for generalization is a triangle connecting a superclass to

subclass. Fig. 3.1 An inheritance hierarchy The dangling ellipsis in the above figure indicates that there are additional subclasses that are not shown in the diagram. This may be since there is no room on the sheet and they are shown elsewhere or may be because enumeration of subclasses is still incomplete. You can also see equipment type written next to the triangle. This is called as a discriminator. “A discriminator is an attribute of enumeration type that indicates which property of an object is being abstracted by a particular generalization relationship.” What is the use of generalization? Generalization is a useful construct for both conceptual modeling and implementation. Overriding Features: I think you are all familiar with this term. A subclass may override a superclass feature by defining a feature with the same name. Here you can see that the subclass feature refines and replaces the superclass feature. What is the need for this feature? The reasons are many to specify behavior that depends on the subclass to tighten the specification of a feature. better performance

12 Aggregation – I think by now, all of you know what is an aggregation? It is a strong form of association in which an aggregate is made of components. Components are part of the aggregate. Aggregation vs. Association – Aggregation is a special form of association not an independent concept. If two objects are bound by a part-whole relationship, it is an aggregation .If two objects are usually considered independent, even though they may be linked, it is an association. Some possible tests are: i) Would you use the phrase part of? ii) Are some operations on the whole automatically applied to its parts? iii) Are some attribute values propagated from the whole to all or some parts iv) Is there an intrinsic asymmetry to the association, where one object class is subordinate to the other?

Fig.4.1 Aggregation and association

In the figure, a company is an aggregation of its divisions, which in turns aggregations of departments; a company is indirectly an aggregation of departments. The decision to use aggregation is a matter of judgment and is often arbitrary. Aggregation vs. Generalization - Aggregation is not the same as generalization. Aggregation relates instances .Two distinct objects are involved; one of them part of other. While generalization relates classes and is a way of structuring the description of a single object. With generalization, an object is simultaneously an instance of the superclass and an instance of the subclass.

Aggregation is called “a part of” relationship; generalization is often called “a kind of” or “is-a “relationship.

Fig.4.2. Aggregation and generalization

The above figure shows the aggregation and generalization in the case of a desk lamp. Aggregation is sometimes called an “and-relationship” and generalization an “or- relationship”. Recursive Aggregates Aggregation can be fixed, variable or recursive. A fixed aggregate has a fixed structure; the number and types of subparts are predefined. The desk lamp in figure 4.2 is a fixed aggregate. A variable aggregate has a finite number of levels, but the number of parts may Vary.The Company in Fig.4.1 is a variable aggregate. A recursive aggregate contains, directly or indirectly, an instance of the same kind of aggregate; the number of potential levels is unlimited.Fig4.3 shows a recursive aggregate.

concrete classes may be leaf classes in the inheritance tree. Now to get a clear idea about look at the below figure.

Fig.4.5 Object model defining abstract and concrete class

Fig 4.6 Concrete classes

All the classes are concrete classes.

14 Generalization as Extension and Restriction : By now you are all familiar with what is meant by generalization. In generalization, an instance of a class is an instance of a class is an instance of all ancestors of the class. Therefore you can say that all ancestor class features must apply to the subclass instances. This includes not only the attributes on the ancestor classes but also the operations on the ancestor class. A subclass may include many features, which is called as an extension. For example, fig.4. extends class Employee with three subclasses that inherit all Employee features and add new features of their own. A subclass may also constrain ancestor attributes. This is called restriction because it restricts the values that instances can assume. For example, a circle is an ellipse whose major and minor axes are equal.Arbitary changes to the attribute values of a restricted subclass may cause it to violate the constraints, such that the result no longer belongs to the original subclass. This is not a problem from the perspective of the superclass because the result is still a valid superclass instance. For example, a circle that is scaled unequally in the x and y dimensions remains an ellipse but is no longer a circle.

  • The inherited features can be renamed in a restriction For example, the inherited features can be renamed the diameter. Class membership can be defined in two ways: implicitly by rule or explicitly by enumeration. Overriding Operations: Overriding is done for many reasons:

Here in the above example, Amphibious Vehicle is a join class. If a class can be refined on several distinct and independent dimensions, then use multiple generalizations. Accidental Multiple Inheritance An instance of a join class is inherently an instance of all the ancestors of the join class. For example, an instructor is inherently both faculty and student. But suppose lets say about a professor at HV taking classes at MIT.You can see there is no class to describe the combination .This is a case of accidental multiple inheritance.

Fig. Workaround for accidental multiple inheritance

16 Metadata -is data that describes other data. For example, the definition of a class is metadata. Models are inherently metadata, since they describe the things being modeled. 17 Candidate Keys – It is a minimal set of attributes that uniquely identifies an object or link. It means you can‟t discard an attribute from the candidate key and still distinguish all objects and links. A class or association may have one or more candidate keys, each of which may have different combinations and numbers of attributes. The object id is always a candidate key for a class. One or more combinations of related objects are candidate keys for associations. A candidate key is delimited with braces in an object model.

Fig. Comparison of multiplicity with candidate keys for binary associations 18 Constraints : They are functional relationships between entities of an object model.