Object relationship and association in ooad methodology

Association (object-oriented programming) - Wikipedia

Objects Relationships Three types of relationships among objects are: Association. 3 Associations A reference from one class to another is an association. . Object Modeling with UML – A Practical Approach By Doug Rosenberg ISBN. OOAD Object Model - Learn Object Oriented Analysis and Design in simple and easy Functional Modelling, UML Approach of Analysis, Object Oriented Design , Association depicts the relationship between objects of one or more classes. In UML there are five different types of relationships: association, aggregation, composition, Association in object oriented programming.

In object-oriented paradigm, polymorphism implies using operations in different ways, depending upon the instance they are operating upon.

Polymorphism allows objects with different internal structures to have a common external interface. Polymorphism is particularly effective while implementing inheritance.

Example Let us consider two classes, Circle and Square, each with a method findArea. Though the name and purpose of the methods in the classes are same, the internal implementation, i. When an object of class Circle invokes its findArea method, the operation finds the area of the circle without any conflict with the findArea method of the Square class.

Generalization and Specialization Generalization and specialization represent a hierarchy of relationships between classes, where subclasses inherit from super-classes.

Generalization In the generalization process, the common characteristics of classes are combined to form a class in a higher level of hierarchy, i. Specialization Specialization is the reverse process of generalization.

Here, the distinguishing features of groups of objects are used to form specialized classes from existing classes. It can be said that the subclasses are the specialized versions of the super-class. The following figure shows an example of generalization and specialization. Links and Association Link A link represents a connection through which an object collaborates with other objects. Through a link, one object may invoke the methods or navigate through another object.

A link depicts the relationship between two or more objects. Association Association is a group of links having common structure and common behavior. Association depicts the relationship between objects of one or more classes.

A link can be defined as an instance of an association. Degree of an Association Degree of an association denotes the number of classes involved in a connection. Degree may be unary, binary, or ternary. A unary relationship connects objects of the same class. A binary relationship connects objects of two classes. A ternary relationship connects objects of three or more classes.

Cardinality Ratios of Associations Cardinality of a binary association denotes the number of instances participating in an association. Aggregation or Composition Aggregation or composition is a relationship among classes by which a class can be made up of any combination of objects of other classes. It allows objects to be placed directly within the body of other classes.

An aggregate object is an object that is composed of one or more other objects. Benefits of Object Model Now that we have gone through the core concepts pertaining to object orientation, it would be worthwhile to note the advantages that this model has to offer. It is easy to maintain. Suppose a module develops an error, then a programmer can fix that particular module, while the other parts of the software are still up and running.

It supports relatively hassle-free upgrades. It enables reuse of objects, designs, and functions. It reduces development risks, particularly in integration of complex systems. In object-oriented software engineering, the software developer identifies and organizes the application in terms of object-oriented concepts, prior to their final representation in any specific programming language or software tools. Phases in Object-Oriented Software Development The major phases of software development using object—oriented methodology are object-oriented analysis, object-oriented design, and object-oriented implementation.

Object—Oriented Analysis In this stage, the problem is formulated, user requirements are identified, and then a model is built based upon real—world objects. The analysis produces models on how the desired system should function and how it must be developed.

The models do not include any implementation details so that it can be understood and examined by any non—technical application expert. Object—Oriented Design Object-oriented design includes two main stages, namely, system design and object design. System Design In this stage, the complete architecture of the desired system is designed.

Lecture Notes on Object-Oriented Programming

The system is conceived as a set of interacting subsystems that in turn is composed of a hierarchy of interacting objects, grouped into classes. System design is done according to both the system analysis model and the proposed system architecture.

Here, the emphasis is on the objects comprising the system rather than the processes in the system. Object Design In this phase, a design model is developed based on both the models developed in the system analysis phase and the architecture designed in the system design phase. All the classes required are identified.

The associations between the identified classes are established and the hierarchies of classes are identified. Besides, the developer designs the internal details of the classes and their associations, i. Object—Oriented Implementation and Testing In this stage, the design model developed in the object design is translated into code in an appropriate programming language or software tool.

The databases are created and the specific hardware requirements are ascertained. Once the code is in shape, it is tested using specialized techniques to identify and remove the errors in the code. The essential features are relative to the context in which the object is being used. Encapsulation Encapsulation is the process of binding both attributes and methods together within a class.

The class has methods that provide user interfaces by which the services provided by the class may be used. Modularity Modularity is the process of decomposing a problem program into a set of modules so as to reduce the overall complexity of the problem.

3.2 Associations and Links

Modularity can be visualized as a way of mapping encapsulated abstractions into real, physical modules having high cohesion within the modules and their inter—module interaction or coupling is low. Through hierarchy, a system can be made up of interrelated subsystems, which can have their own subsystems and so on until the smallest level components are reached. Hierarchy allows code reusability.

For example, a flower is composed of sepals, petals, stamens, and carpel. Typing According to the theories of abstract data type, a type is a characterization of a set of elements. In OOP, a class is visualized as a type having properties distinct from any other types. Typing is the enforcement of the notion that an object is an instance of a single class or type.

It also enforces that objects of different types may not be generally interchanged; and can be interchanged only in a very restricted manner if absolutely required to do so. The operation is checked only at the time of execution, as in the programming language Smalltalk.

This relationship is often known as a contains-a relationship, because the whole contains its parts. For example, an organization contains teams and workers, and if the organization ceases to exist, its teams and workers also cease to exist. The specific individuals who represent the workers would still exist, but they would no longer be workers of the organization, because the organization would no longer exist.

Composition is shown using a filled diamond attached to the class that represents the whole.

object relationship and association in ooad methodology

The relationships between a team, its workers, and an organization are shown in Figure The filled-in diamond at the endpoint of the subteam relationship in Figure indicates that teams contain their subteams.

As a UML rule, composition is used only with binary associations. Notice how much information is being communicated in Figure It shows that an organization may contain 0 to 20 teams and 0 to 1, workers. Furthermore, each team has 2 to 5 workers and each worker may be a member of 0 to 2 teams. In addition, a team may contain 0 to 3 subteams. To determine if you should use an aggregation or composition, ask yourself a few questions. First, if the classes are related to one another, use an association.

Next, if one class is part of the other class, which is the whole, use aggregation; otherwise, use an association. For example, Figure shows that workers are part of a team and organization, teams are part of an organization, and subteams are part of teams.

Finally, if the part must belong to one whole only, and the whole is responsible for creating and destroying its parts, use composition; otherwise, simply use aggregation. For example, Figure shows that a team and worker must belong to one organization only, and the organization is responsible for determining or creating and destroying its teams and workers.

It also shows that a subteam must belong to one team only, and the team is responsible for determining or creating and destroying its subteams. If this is unclear, keep things simple and use associations without aggregation or composition. Composition also may be shown by graphically nesting classes, in which a nested class's multiplicity is shown in its upper-right corner and its rolename is indicated in front of its class name.

Separate the rolename from the class name using a colon. Figure uses the graphical nesting of teams and workers in organizations to communicate the same information as shown in Figure Alternate form of composition for associations Figure uses the graphical nesting of subteams within teams to communicate the same information as Figure and Figure The result is a nested class inside a nested class.

Doubly nested composition for associations 3. For example, Figure shows that multiplicity between work products and units of work is zero or more for both associations; that is, there may be many work products associated with a single unit of work and there may be many units of work associated with a single work product.

Rather than simply say that there are "many" objects involved in the relationship, you can communicate a more finite number. You can reduce the multiplicity between work products and units of work by asking yourself what you need to know about a unit of work so that you can define a more specific multiplicity one that isn't unbounded on the high-end.

Likewise, you can ask yourself the same question about the association between work product and units of work. If you have a work product and the name of a unit of work, you can determine whether a relationship exists between the two; likewise, if you have a unit of work and the name of a work product, you can determine whether a relationship exists between those two.

The trick is to document precisely what information is needed so you can identify the objects on the other end of the relationship. This is where the qualifier comes into play.

Other Object Oriented Class Relationships | Atomic Object

Essentially, a qualifier is a piece of information used as an index to find the objects on the other end of an association. A qualifier is shown as a small rectangle attached to a class where an object of the class, together with a value for the qualifier, reduces the multiplicity on the other end of the association.

Qualifiers have the same notation as attributes, have no initial values, and must be attributes of the association or the class on the other end of the association.

The relationships between work products and units of work and their qualifiers are shown in Figure The qualifiers indicate that a work product with the name of a unit of work may identify a unit of work, and that a unit of work with the name of a work product may identify a work product. Notice that I've reduced the multiplicity of The qualifier enables me to do this.

As a UML rule, qualifiers are used only with binary associations. Qualifiers for associations 3. For example, the project management system involves various specific relationships, including specific manage, lead, execute, input, output, and other relationships between specific projects, managers, teams, work products, requirements, systems, and so forth. A link is an instance of an association, and the UML supports different types of links that correspond to the different types of associations.

The general rules for representing links in a UML diagram are as follows: Label links with their association names, and underline the names to show that they are specific instances of their respective associations. Ensure that link ends are consistent with their corresponding association ends.

Translate association multiplicity into one or more specific links between specific objects. The next few sections show how to apply these rules to the various link types. For example, a specific worker is related to specific units of work and work products in the project management system.

A link may have its association name shown near the path fully underlinedbut links do not have instance names. Figure shows various objects associated with the classes shown in Figure and the association classes shown in Figure Additionally, Figure includes several link objects.

Figure describes an anonymous worker that performs a projecta unit of workthat consumes a Problem Statement work product and produces a system work product. ResponsibleFor and Performed are two links in Figure Binary links The only difference between a binary link and a binary association is that the binary link is specific, and thus has its association name underlined.

object relationship and association in ooad methodology

For example, the utilization of a specific worker involves the worker, the worker's specific units of work, and the worker's specific work products in the project management system.

A link may have its association name shown near the path, and because a link is specific, its association name should be fully underlined. However, links do not have instance names. As a UML rule, aggregation, composition, and qualifiers may not be used with n-ary links. Additionally, Figure includes a link object named Utilization. Figure describes the utilization of an anonymous team, its work, and work products.

Structural features include attribute values and perhaps other links. Behavioral features include operations and methods, which are shared by all the links of an association class. Whenever an association has a related association class, each of its links has a corresponding link object. This link object defines attribute values for the link's structural features. In addition, the behavioral features defined by the link's association class apply to the link objects. In a UML object diagram, a link object is shown as an object rectangle attached by a dashed-line path to its link path in a binary link, or attached to its link diamond in an n-ary link.

As with all UML elements representing specific objects or links, link object names should be fully underlined.