Structural Modelling, Basic Behavioral Modeling,lArchitectural Modeling

 

Structural Things

Structural things define the static part of the model. They represent the physical and conceptual elements. Following are the brief descriptions of the structural things.

Class − Class represents a set of objects having similar responsibilities.

class

Interface − Interface defines a set of operations, which specify the responsibility of a class.

Interface

Collaboration −Collaboration defines an interaction between elements.

Collaboration

Use case −Use case represents a set of actions performed by a system for a specific goal.

Use case

Component −Component describes the physical part of a system.

Component

Node − A node can be defined as a physical element that exists at run time.

Node

Behavioral Things

A behavioral thing consists of the dynamic parts of UML models. Following are the behavioral things −

Interaction − Interaction is defined as a behavior that consists of a group of messages exchanged among elements to accomplish a specific task.

Interaction

State machine − State machine is useful when the state of an object in its life cycle is important. It defines the sequence of states an object goes through in response to events. Events are external factors responsible for state change

State machine

Grouping Things

Grouping things can be defined as a mechanism to group elements of a UML model together. There is only one grouping thing available −

Package − Package is the only one grouping thing available for gathering structural and behavioral things.

Package



Annotational Things

Annotational things can be defined as a mechanism to capture remarks, descriptions, and comments of UML model elements. Note - It is the only one Annotational thing available. A note is used to render comments, constraints, etc. of an UML element.

Note

Ezoic

Relationship

Relationship is another most important building block of UML. It shows how the elements are associated with each other and this association describes the functionality of an application.

There are four kinds of relationships available.

Dependency

Dependency is a relationship between two things in which change in one element also affects the other.

Dependency

Association

Association is basically a set of links that connects the elements of a UML model. It also describes how many objects are taking part in that relationship.

Association



Generalization

Generalization can be defined as a relationship which connects a specialized element with a generalized element. It basically describes the inheritance relationship in the world of objects.

Generalization

Realization

Realization can be defined as a relationship in which two elements are connected. One element describes some responsibility, which is not implemented and the other one implements them. This relationship exists in case of interfaces.

Realization










Class Notation

UML class is represented by the following figure. The diagram is divided into four parts.

  • The top section is used to name the class.

  • The second one is used to show the attributes of the class.

  • The third section is used to describe the operations performed by the class.

  • The fourth section is optional to show any additional components.

Class Notation

Classes are used to represent objects. Objects can be anything having properties and responsibility.

Ezoic

Object Notation

The object is represented in the same way as the class. The only difference is the name which is underlined as shown in the following figure.

Object Notation

As the object is an actual implementation of a class, which is known as the instance of a class. Hence, it has the same usage as the class.

Interface Notation

Interface is represented by a circle as shown in the following figure. It has a name which is generally written below the circle.

Interface Notation

Interface is used to describe the functionality without implementation. Interface is just like a template where you define different functions, not the implementation. When a class implements the interface, it also implements the functionality as per requirement.

Ezoic

Collaboration Notation

Collaboration is represented by a dotted eclipse as shown in the following figure. It has a name written inside the eclipse.

Collaboration Notation

Collaboration represents responsibilities. Generally, responsibilities are in a group.

Use Case Notation

Use case is represented as an eclipse with a name inside it. It may contain additional responsibilities.

Use case Notation

Use case is used to capture high level functionalities of a system.

Ezoic

Actor Notation

An actor can be defined as some internal or external entity that interacts with the system.

Actor Notation

An actor is used in a use case diagram to describe the internal or external entities.

Initial State Notation

Initial state is defined to show the start of a process. This notation is used in almost all diagrams.

Initial state Notation

The usage of Initial State Notation is to show the starting point of a process.

Final State Notation

Final state is used to show the end of a process. This notation is also used in almost all diagrams to describe the end.

Final state Notation

The usage of Final State Notation is to show the termination point of a process.

Active Class Notation

Active class looks similar to a class with a solid border. Active class is generally used to describe the concurrent behavior of a system.

Active class Notation

Active class is used to represent the concurrency in a system.

Component Notation

A component in UML is shown in the following figure with a name inside. Additional elements can be added wherever required.

Component Notation

Component is used to represent any part of a system for which UML diagrams are made.

Node Notation

A node in UML is represented by a square box as shown in the following figure with a name. A node represents the physical component of the system.

Node Notation

Node is used to represent the physical part of a system such as the server, network, etc.

Behavioral Things

Dynamic parts are one of the most important elements in UML. UML has a set of powerful features to represent the dynamic part of software and non-software systems. These features include interactions and state machines.

Interactions can be of two types −

  • Sequential (Represented by sequence diagram)

  • Collaborative (Represented by collaboration diagram)

Interaction Notation

Interaction is basically a message exchange between two UML components. The following diagram represents different notations used in an interaction.

Interaction Notation

Interaction is used to represent the communication among the components of a system.

State Machine Notation

State machine describes the different states of a component in its life cycle. The notations are described in the following diagram.

State machine Notation

State machine is used to describe different states of a system component. The state can be active, idle, or any other depending upon the situation.

Grouping Things

Organizing the UML models is one of the most important aspects of the design. In UML, there is only one element available for grouping and that is package.

Package Notation

Package notation is shown in the following figure and is used to wrap the components of a system.

package Notation

Annotational Things

In any diagram, explanation of different elements and their functionalities are very important. Hence, UML has notes notation to support this requirement.

Note Notation

This notation is shown in the following figure. These notations are used to provide necessary information of a system.

Note Notation

Relationships

A model is not complete unless the relationships between elements are described properly. The Relationship gives a proper meaning to a UML model. Following are the different types of relationships available in UML.

  • Dependency

  • Association

  • Generalization

  • Extensibility

Dependency Notation

Dependency is an important aspect in UML elements. It describes the dependent elements and the direction of dependency.

Dependency is represented by a dotted arrow as shown in the following figure. The arrow head represents the independent element and the other end represents the dependent element.

Dependency Notation

Dependency is used to represent the dependency between two elements of a system

Association Notation

Association describes how the elements in a UML diagram are associated. In simple words, it describes how many elements are taking part in an interaction.

Association is represented by a dotted line with (without) arrows on both sides. The two ends represent two associated elements as shown in the following figure. The multiplicity is also mentioned at the ends (1, *, etc.) to show how many objects are associated.

Association Notation

Association is used to represent the relationship between two elements of a system.

Generalization Notation

Generalization describes the inheritance relationship of the object-oriented world. It is a parent and child relationship.

Generalization is represented by an arrow with a hollow arrow head as shown in the following figure. One end represents the parent element and the other end represents the child element.

Generalization Notation

Generalization is used to describe parent-child relationship of two elements of a system.

Extensibility Notation

All the languages (programming or modeling) have some mechanism to extend its capabilities such as syntax, semantics, etc. UML also has the following mechanisms to provide extensibility features.

  • Stereotypes (Represents new elements)

  • Tagged values (Represents new attributes)

  • Constraints (Represents the boundaries)

Extensibility Notation

Extensibility notations are used to enhance the power of the language. It is basically additional elements used to represent some extra behavior of the system. These extra behaviors are not covered by the standard available notations.










Refer PPT on ADVANCED CLASSES


Classifiers

 

A classifier is a mechanism which describes structural and behavioral features. Class is the frequently used classifier. Every classifier represents structural aspects in terms of properties and behavioral aspects in terms of operations. Beyond these basic features, there are several advanced features like multiplicity, visibility, signatures, polymorphism and others.

 

In general, all the modeling elements that can have instances are called as classifiers. For example, classes have instances known as objects. Some elements like packages and a generalization does not have instances.  Classifiers in UML are as follows:

 

uml classifiers

 

The graphical representation of the classifiers is as follows:

 

uml classifiers symbols

 

Let’s look at the advanced features (specific information that can be represented) of classes in UML.

 

Visibility

 

One of the important features that can be applied to the classifier’s attributes and operations is the visibility. The visibility feature specifies whether a classifier can be used or accessed by the other classifiers. The four access specifiers in UML are as shown below:

 

uml visibility access specifiers

 

Example:

 

uml visibility example

 

Scope

 

Another feature that can be applied to the classifier’s attributes and operations is the scope. The scope of an attribute or an operation denotes whether they have their existence in all the instances of the classifier or only one copy is available and is shared across all the instances of the classifier. The scope specifiers in UML are:

 

uml scope specifiers

 

A classifier scoped feature is graphically represented by underlining the feature within the classifier. All other normal features are treated as instanced scope.

 

Example:

 

uml scope example

 

Abstract, Root, Leaf and Polymorphic elements

 

While developing class diagrams, it is common to use generalization relationship to model generalization-specialization relationships between a group of classes.

 

The classes at the top of the hierarchy are more generalized or abstract and the classes lower in the hierarchy are more specialized. To represent abstract classes for which we cannot create instances, the class name is written in italics in UML. To represent abstract methods, we write the operation signature in italics.

 

We can also represent leaf and root classes in UML. A class which has no child classes is known as a leaf class. Such a class can be represented by writing leaf as a property under the class name.

 

Similarly, a class with no parents is known as a root class and such a class can be represented by writing root as a property as a property under the class name.

 

In class hierarchies it is common for the classes to have methods with same signatures. This feature of declaring methods with same signatures is known as polymorphism. Such methods are represented in UML by writing their signatures in italics.

 

We can also specify that a method cannot be overrided by marking the method with the leaf property written beside the method signature.

 

Example:

 

classes abstract root leaf polymorphism

 

Multiplicity

 

When modeling classes it is reasonable to assume that a class can have any number of instances. In some cases a class might not have any instances at all. Such a class with no instances is called a utility class which contains only attributes and operations with the classifier scope.

 

A class with exactly one instance is called a singleton class. Similarly other classes might have any number of instances which is the default in UML.

 

The specification of how many instances a class can have is known as multiplicity. In UML, we can mention the multiplicity as an expression in the top right hand corner of the class icon. Attributes too can have multiplicity. The multiplicity of an attribute is represented in brackets after the attribute name.

 

Example:

 

class multiplicity

 

Attributes

 

While modeling classes, it is reasonable to write only the attribute name. Along with the name, you can also specify multiplicity, visibility and scope. Apart from these features, we can also specify the type, initial value and changeability of each attribute. The syntax of an attribute in UML is:

 

[visibility] name [multiplicity] [: type] [=initial value] [{property string}]


Examples:

 

advanced uml attributes

 

The three predefined properties that can be used with attributes in UML are:

 

class attributes properties

 

Example:

 

advanced attributes example

 

Operations

 

While modeling classes, it is simple to write only the operation name. Along with the name we can also mention the visibility and scope. Apart from these basic details, we can also specify the return type, parameters, concurrency semantics and other features. The syntax of an operation in UML is:

 

[visibility] name [(parameters-list)] [: return-type] [{property-string}]

 

Examples:

 

advanced operations examples

 

The signature of parameter in the parameters list of an operation is as follows:

 

[direction] name :type [=initial value]

 

Direction may be anyone of the following values:

 

parameter directions

 

The operation name, parameters list and its return type is collectively known as the signature of the operation.

 

There are four predefined properties (stereotypes) that can be applied to operations, in UML. They are:

 


uml operation properties







ADVANCED RELATIONSHIP IN UML

Dependency

 

The dependency relationship is also known as using relationship i.e., if the specification of one thing (for example Graphics class code) changes then it will automatically affect the behavior of another thing (for example Hello class using the drawstring method of Graphics class) that uses it. A dependency relationship is graphically represented as a dashed arrow.

 

uml dependency

 

In general, a plain dependency relationship is reasonable for representing the using relationship between two things. But, if the user needs to specify extra information like the nature of the dependency relationship, he/she can use the predefined stereotypes that can be applied to dependency relationship.

 

There are about 17 such stereotypes and are organized into 6 groups based on which things are participating in the dependency relationship. The stereotypes are as follows:

 

First group consists of eight stereotypes that apply to dependency relationship between classes. They are as follows:

 

class dependency stereotypes

 

Examples:

 

<<bind>>

bind stereotype

 

<<derive>>

derive stereotype

 

<<friend>>

friend stereotype

 

<<instanceOf>>

instanceof stereotype

 

<<instantiate>>

instantiate stereotype

<<powertype>>

powertype stereotype

 

<<refine>>

refine stereotype

<<use>>

use stereotype

 

There are two stereotypes that apply to dependencies between packages. They are:

 

package dependency stereotypes

 

Examples:

 

<<access>>

access example

 

<<import>>

import example

 

Two stereotypes apply to dependency relationship among use case. They are:

 

use case dependency stereotypes

 

Examples:

 

<<extend>>

extend use case example

 

<<include>>

include use case example

 

Three stereotypes apply to interactions among objects. They are:

 

object dependency stereotype

 

Examples:

 

<<become>>

become dpendency

 

<<call>>

call dependency example

 

<<copy>>

copy dependency example

 

One stereotype applies to dependencies in the context of state machines:

 

state dependency stereotype

 

One stereotype applies to dependencies in the context of subsystem:

 

subsystem dependency stereotype

 

Example:

 

trace dependency example

 

Generalization

 

A generalization relationship represents generalization-specialization relationship between classes. The class with the general structure and behavior is known as the parent or superclass and the class with specific structure and behavior is known as the child or subclass. Consider the below class hierarchy:

 

uml generalization example

 

Shape class is the parent or super class and the remaining three classes namely Rectangle, Circle and Polygon are the child or subclasses of the Shape class.

 

A subclass in the generalization relationship automatically inherits the state and behavior of the superclass. The generalization relationship is also known as the “is-a” relationship. If a class has only one parent, such inheritance is known as single inheritance and if a class has one or more parents, such inheritance is known as multiple inheritance.

 

To represent extra semantics in a generalization relationship, UML provides one stereotype and four constraints. The stereotype on generalization relationship is:

 

generalization stereotype

 

There are four standard constraints that apply to the generalization relationship:

 

generalization constraints

 

Association

 

Association is a structural relationship which denotes a connection between two or more things. The association relationship can represent either physical or logical connections between things. The graphical representation of the association relationship is a solid line.

 

The four basic adornments for an association relationship are: name, role at each end of the association, multiplicity at each end of the association and aggregation. Over these basic features, there are other advanced features like: navigation, visibility, qualification, composition and association classes.

 

association example

 

Navigation

 

Given an association between two things, we can navigate from one thing to another and vice versa. By default the navigation of an association is bidirectional. In some cases we may need to navigate in only direction. For example, given an order, we can get the details of the products in the order. But, if we consider a product, there might be no need to know about the order to which it belongs.

 

navigation example

 

Visibility

 

Given an association, we can navigate from one object to another. However, in some situations we may want to limit the visibility (access) of an object to the objects outside the association relationship.

 

To limit the visibility of an object, we can use the visibility specifiers: public (+), private (-) and protected (#). For example, a usergroup object can access the user object and an user object can access the password. If, private visibility is specified for the password object, the usergroup object cannot access the password of the user object.

 

association visibility example

 

Qualification

 

In binary associations, where two classes are connected together, if one object of a class has to identify a set of instances of another class, we can use qualifiers. A qualifier is a set of attributes of an association which is used to identify a set of instances of a class.

 

Each qualifier is represented with a name and type in a rectangle box at the qualified end of the association relationship. For example, a bank object is able to recognize the person (account holder) based on the account number. So, account number is the qualifier which is used to identify an account holder.

 

association qualification example

 

Composition

 

The composition is a flavor of association relationship. Composition as well as aggregation relationships represent whole-part relationships, in which one thing is a part of the other thing.

 

There is a simple difference between the association and composition relationships. In composition, the lifetime of the part is dependent of the lifetime of the whole thing. Where as in aggregation, the lifetime of the part is independent of the whole thing.

 

Composition is graphically represented by adorning the association relationship with a filled diamond head near the whole end.

 

association composition example

 

Association Class

 

Sometimes in an association relationship, the association might have attributes or properties like a class does. In such cases, it is modeled as an association class. An association class in UML is represented with a class icon attached to the association with a dashed line.

 

association class

 

Apart from the above advanced features, UML provides six constraints that can be applied to an association. They are:

 

association constraints

 

Realization

 

Realization is a semantic relationship between classifiers, where one classifier provides the specification which is implemented by the other classifier. Realization can exist between an interface and class, interface and a component and between a use case and collaboration.

 

Realization is graphically represented as dashed line with a hollow arrow head pointing towards the classifier which provides the specification.

 

uml realization relationship example

 


 


 





Comments

Popular posts from this blog

Object Oriented Design

Assignment # 3