47
Unit I/UML/MCA/NIE Venkata Ratnam K 1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Embed Size (px)

Citation preview

Page 1: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 1

Introducing the UML and UML Diagrams

Page 2: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 2

Why Model?

Modeling achieves four aims:

Helps you to visualize a system as you want it to be. Permits you to specify the structure or behavior of a system. Gives you a template that guides you in constructing a system. Documents the decisions you have made.

You build models of complex systems because you cannot comprehend such a system in its entirety.

You build models to better understand the system you are developing.

What Is a Model?

A model is “a complete description of a system from a particular perspective.” A model is a simplification of reality.

Page 3: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 3

Importance of Modeling

Unified Modeling Language (UML)

used for both database and software modeling version 1.1 was adopted in November 1997 by the Object Management Group (OMG) as a standard language for object-

oriented analysis and design Initially based on a combination of the Booch, OMT (Object Modeling

Technique) and OOSE (Object-Oriented Software Engineering) methods, UML was refined and extended by a consortium of several companies, and is undergoing minor revisions by the OMG Revision Task Force.

Ivar Jacobson is known as the father of Use Cases.

Four Principles of Modeling

The model you choose influences how the problem is attacked.

Every model may be expressed at different levels of precision.

The best models are connected to reality.

No single model is sufficient.

Page 4: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 4

What is UML?

Is a language. It is not simply a notation for drawing diagrams, but a complete language for capturing knowledge(semantics) about a subject and expressing knowledge(syntax) regarding the subject for the purpose of communication.

Applies to modeling and systems. Modeling involves a focus on understanding a subject (system) and capturing and being able to communicated in this knowledge.

It is the result of unifying the information systems and technology industry’s best engineering practices (principals, techniques, methods and tools).

used for both database and software modeling

Page 5: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 5

Overview of the UML

The UML is a language for

visualizing

specifying

constructing

documenting

the artifacts of a software-intensive system

Page 6: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 6

Visual modeling (visualizing) A picture is worth a thousand words!

- Uses standard graphical notations- Semi-formal- Captures Business Process from enterprise information systems to

distributed Web-based applications and even to hard real time embedded systems

Specifying building models that are: Precise, Unambiguous, Complete UML symbols are based on well-defined syntax and semantics. UML addresses the specification of all important analysis, design, and

implementation decisions.

Page 7: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 7

Constructing

Models are related to OO programming languages. Round-trip engineering requires tool and human intervention to avoid

information loss Forward engineering — direct mapping of a UML model into code. Reverse engineering — reconstruction of a UML model from an

implementation.

Documenting Architecture, Requirements, Tests, Activities (Project planning,

Release management)

Page 8: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 8

Conceptual Model of the UML

» To understand the UML, you need to form a conceptual model of the language, and this requires learning three major elements.

Elements:1. Basic building blocks2. Rules3. Common Mechanisms

Basic Building Blocks of the UML

The vocabulary of the UML encompasses three kinds of building blocks:

» Things » Relationships » Diagrams

Page 9: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 9

Things in the UML

There are four kinds of things in the UML:

1. Structural — nouns of UML models.

2. Behavioral — dynamic (verbal) parts of UML models.

3. Grouping — organizational parts of UML models.

4. Annotational — explanatory parts of UML models.

Page 10: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 10

1.Structural Things

These are the Nouns and Static parts of the model. These are representing conceptual or physical elements.

There are seven kinds of structural things:

1. Class

2. Interface

3. Collaboration

4. Use Case

5. Active Class

6. Component

7. Node

Page 11: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 11

1.Class

Is a description of set of objects that share the same attributes, operations

methods, relationships and semantics.

2.Interface

A collection of operations that specify a service (for a resource or an action) of a class or component. It describes the externally visible behavior of that element

Windoworiginsize

open( )close( )move( )

Name

Attributes

Operations

A Simple ClassA Simple Interface

Iname

<<interface>>IWindow

open()close()

name

operations

Page 12: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 12

3.Collaboration

– Define an interaction among two or more classes.– Define a society of roles and other elements.– Provide cooperative behavior.– Capture structural and behavioral dimensions.– UML uses ‘pattern” as a synonym (careful)

4.Use Case– A sequence of actions that produce an observable result for a specific actor.

– A set of scenarios tied together by a common user goal.

– Provides a structure for behavioral things.

– Realized through a collaboration (usually realized by a set of actors and the system to be built).

Name

Behavior

Place order

Page 13: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 13

5. Active Class– Special class whose objects own one or more processes or threads.– Can initiate control activity.

6. Component Replaceable part of a system. Components can be packaged logically. Conforms to a set of interfaces. Provides the realization of an interface. Represents a physical module of code

7. Node Element that exists at run time. Represents a computational resource. Generally has memory and processing power.

Orderform.java

Web Server

Event Manager

Threadtime

suspend()flush()

Name

attributes

operations

Heavy border

Page 14: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 14

2.Behavioral Things These are Verbs of UML models. These are Dynamic parts of UML models: “behavior over time and

space” Usually connected to structural things in UML.

There are two kinds of Behavioral Things:

1.Interaction Is a behavior of a set of objects comprising of a set of messages

exchanges within a particular context to accomplish a specific purpose.

2.State Machine Is a behavior that specifies the sequences of states an object or an

interaction goes through during its lifetime in response to events, together with its responses to those events.

display

Idle Waiting

Page 15: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 15

3.Grouping Things

These are the organizational parts of the UML models.There is one primary kind of group thing:

1.Packages

- General purpose mechanism for organizing elements into groups.

- Purely conceptual; only exists at development time.

- Contains behavioral and structural things.

- Can be nested.

- Variations of packages are: Frameworks, models, & subsystems.

Business rules

Page 16: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 16

4.Annotational Things

These are Explanatory parts of UML models These are the Comments regarding other UML elements (usually called

adornments in UML)

There is one primary kind of annotational thing:

1.NoteA note is simply a symbol for rendering constraints and comments attached to an element or collection of elements.

Is a best expressed in informal or formal text.

comments

Page 17: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 17

Relationships

There are four kinds of relationships:

1. Dependency

2. Association

3. Generalization

4. Realization

» These relationships tie things together.

» It is a semantic connection among elements.

» These relationships are the basic relational building blocks of the UML.

Page 18: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 18

1. DependencyIs a semantic relationship between two things in which a change to one thing (the independent thing) may affect the semantics of the other thing

( the dependent thing).

2. Association

Is a structural relationship that describes a set of links, a link being a connection among objects.

employer employee

0..1 *

Page 19: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 19

Aggregation

» Is a special kind of association. It represents a structural

relationship between the whole and its parts.

» Represented by black diamond.

3. GeneralizationIs a specialization/generalization relationship in which objects of the specialized element (the child) are more specific than the objects of the generalized element.

Page 20: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 20

4. Realization

a semantic relationship between two elements, wherein one element guarantees

to carry out what is expected by the otherelement.

Where?Between interfaces and classes that realize them…Between use cases and the collaborations that realize them...

Page 21: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 21

Diagrams A diagram is the graphical presentation of a set of elements. Represented by a connected graph: Vertices are things; Arcs are behaviors.

UML includes nine diagrams:

Use case Diagram Class Diagram; Object Diagram Sequence Diagram; Collaboration Diagram Statechart Diagram Activity Diagram Component Diagram Deployment Diagram

Page 22: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 22

1.Class Diagram Class Diagrams describe the static structure of a system, or

how it is structured rather than how it behaves. A class diagram shows the existence of classes and their

relationships in the logical view of a systemThese diagrams contain the following elements.

– Classes and their structure and behavior– Association, aggregation, dependency,

and inheritance relationships – Multiplicity and navigation indicators

– Role names

These diagrams are the most common diagrams found in O-O modeling systems.

Page 23: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 23

Examples:

Registration Form Registration Manager

StudentCourse Offering

Course

Page 24: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 24

Example

Page 25: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 25

2. Object Diagrams Shows a set of objects and their relationships.

A static snapshot of instances. Object Diagrams describe the static structure of a system at a particular time.

Whereas a class model describes all possible situations, an object model describes a particular situation.

Object diagrams contain the following elements:

Objects which represent particular entities. These are instances of classes.

Links which represent particular relationships between objects. These are instances of associations.

Harry (Student)

Name: “Harry Mat”Major: CS

Page 26: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 26

Page 27: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 27

Use case diagrams

Use Case Diagrams describe the functionality of a system and users of the system.

These diagrams contain the following elements:

Actors : which represent users of a system, including human users and other systems.

Use Cases : which represent functionality or services provided by a system to users.

Registrar Student Maintain Schedule

Page 28: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 28

Example

Page 29: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 29

Sequence Diagrams

Sequence Diagrams describe interactions among classes. These interactions are modeled as exchange of messages.

These diagrams focus on classes and the messages they exchange to accomplish some desired behavior.

Sequence diagrams are a type of interaction diagrams.

Sequence diagrams contain the following elements:

Class roles: which represent roles that objects may play within the interaction.

Lifelines which represent the existence of an object over a period of time.

Activations : which represent the time during which an object is performing an operation.

Messages : which represent communication between objects.

Page 30: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 30

Collaboration DiagramCollaboration Diagrams describe interactions among classes and associations. These interactions are modeled as exchanges of messages between classes through their associations. Collaboration diagrams are a type of interaction diagram.

Collaboration diagrams contain the following elements.Class roles: which represent roles that objects may play within

the interaction. Association roles: which represent roles that links may play within the interaction.

Message flows: which represent messages sent between objects via links. Links transport or implement the delivery of the message.

Page 31: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 31

Page 32: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 32

Statechart Diagrams

Statechart (or state) diagrams describe the states and responses of a class. Statechart diagrams describe the behavior of a class in response to external stimuli.

These diagrams contain the following elements:

States : which represent the situations during the life of an object in which it satisfies some condition, performs some activity, or waits for some occurrence.

Transitions: which represent relationships between the different states of an object.

Page 33: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 33

Page 34: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 34

Activity Diagrams

Activity diagrams describe the activities of a class. These diagrams are similar to statechart diagrams and use similar conventions, but activity diagrams describe the behavior of a class in response to internal processing rather than external events as in statechart diagram.

Swimlanes: which represent responsibilities of one or more objects for actions within an overall activity; that is, they divide the activity states into groups and assign these groups to objects that must perform the activities.

Action States: which represent atomic, or noninterruptible, actions of entities or steps in the execution of an algorithm.

Action flows: which represent relationships between the different action states of an entity.

Object flows: which represent the utilization of objects by action states and the influence of action states on objects.

Page 35: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 35

Page 36: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 36

Component DiagramComponent diagrams describe the organizations and dependencies among software implementation components. These diagrams contain components, which represent distributable physical units, including source code, object code, and executable code.

These are static implementation view of a system.

Deployment DiagramsDeployment diagrams describe the configuration of run-time processing resource elements and the mapping of software implementation components onto them. These diagrams contain components and nodes, which represent processing or computational resources, including computers, printers, etc.

Page 37: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 37

Rules of the UML:

The UML building blocks can’t simply put together in a random fashion. Like any language , the UML has a number of rules that specify what a well-

formed model should look like. well-formed models

Is a model semantically self-consistent and in harmony with all its related models

Semantic rules for:Names — what you can call things.

Scope — context that gives meaning to a name.Visibility — how names can be seen and used.

Integrity — how things properly and consistently relate to one another.

Execution — what it means to run or simulate a dynamic model. Avoid models Elided — certain elements are hidden for simplicity. Incomplete — certain elements may be missing. Inconsistent — no guarantee of integrity.

Page 38: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 38

Common Mechanisms: The UML is made simpler by the presence of some features called common

mechanisms.

There are four kinds of mechanisms;

1. Specifications: It provides a textual statement of the syntax and semantics of the building blocks.

2. Adornments: It provides detail from an element’s specification added to its basic graphical notation.

3. Common divisions: There is a division of class and object and also the division of interface and implementation.

4. Extensibility mechanisms: The UML provides a standard language for software blueprints. The UML is opened,

making it possible to extend the language in controlled ways to express all possible nuances of all models across all time.

Page 39: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 39

The UML’s extensibility mechanisms include

Stereotypes can be used to extend the UML notational elements (extends vocabulary.)

» Name shown in guillements <<stereotype>>

» Stereotypes may be used to classify and extend associations, inheritance relationships, classes, and components

» Examples: – Class stereotypes: boundary, control, entity,

utility, exception – Inheritance stereotypes: includes and extends

– Component stereotypes: subsystem

Ex: << include>>, <<extend>>

Page 40: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 40

Tagged values — extends properties of UML building blocks. Placed in braces beneath the name of the

element to which the property applies

Ex:

Constraints — extends the semantics of UML building blocks. A string placed in braces

Ex: {and}, {or}, {abc}

An Object: Class A{location=server)

Page 41: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 41

Architecture:

Visualizing, specifying, constructing, and documenting a software system demands that the system be viewed from a number of perspectives.

A system’s architecture is perhaps the most important artifact that can be used to manage these different viewpoints and so control the iterative and incremental development of a system throughout of its lifecycle.

s/w architecture is not only concerned with structure and behavior , but also

it’s usage, functionality, performance, resilience, reuse, comprehensibility, economic and technology constraints and trade-offs, and aesthetic concerns.

The below figure illustrates, the architecture of a system can be described by five interlocking views.

Page 42: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 42

Modeling a system’s architecture

Design View Implementation View

Process View

Components Classes, interfaces,collaborations

Active classes

Deployment View

Nodes

Use Case View

Use cases

Design View Implementation View

Process View

Components Classes, interfaces,collaborations

Active classes

Deployment View

Nodes

Use Case View

Use cases

Page 43: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 43

Use case view

Encompasses the use cases that describes the behavior of the system as seen by its end users, analysts, and testers

Design view

Encompasses the classes, interfaces, and collaborations that form the vocabulary of the problem and its solution

Process view

Shows the flow of control among its various parts, including possible concurrency and synchronization mechanisms

Implementation view

Encompasses the artifacts that are used to assemble and release the physical system

Deployment view

Encompasses the nodes that form the system’s hardware topology on which the system executes

Page 44: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 44

Software Development Life Cycle

The UML is largely process- independent

To get the most benefit from the UML, you should consider a process that is

Use case driven — use cases are primary artifact for defining behavior of the system for verifying and

validating the system’s architecture, for testing, and for communicating among the stakeholders of the project. .

Architecture-centric — the system’s architecture is primary artifact for conceptualizing,

constructing, managing, and evolving the system under development.

Iterative— managing streams of executable releases.

Page 45: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 45

Incremental

One that involves the continuous integration of the system’s architecture to produce these releases

This process is furthurly can be broken into phases.

A Phase is the span of time between two major milestones of the process

Page 46: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 46

Lifecycle Phases

Inception Define the scope of the project and develop business case Deliver the product to its users

Elaboration Plan project, specify features, and baseline the architecture

Construction Build the product

Transition Turned over to the user community `

time

Inception Elaboration Construction Transition

Page 47: Unit I/UML/MCA/NIEVenkata Ratnam K1 Introducing the UML and UML Diagrams

Unit I/UML/MCA/NIE Venkata Ratnam K 47

Advantages of UML You can model just about any type of application, running on any type and

combination of hardware, operating system, programming language, and network, in UML.

Used for modeling middleware Built upon the MOF™ meta model for OO modeling UML Profiles (that is, subsets of UML tailored for specific purposes) help you

model Transactional, Real-time, and Fault-Tolerant systems in a natural way.  UML is effective for modeling large, complex software

systems• It is simple to learn for most developers, but provides

advanced features for expert analysts, designers and architects• It can specify systems in an implementation-independent manner• 10-20% of the constructs are used 80-90% of the time• Structural modeling specifies a skeleton that can be refined

and extended with additional structure and behavior• Use case modeling specifies the functional requirements of

system in an object-oriented manner