UML Modeling in Java

Post on 12-Apr-2017

156 views 2 download

Transcript of UML Modeling in Java

Title Layout

2

Course: CSE214 (Object Oriented Programming)Course Teacher: Ms. Rabeya Akhter (RA)Section: P Depertment: CSE(43 Batch)Group Members: 01. Md. Ashaf Uddaula (161-15-7473)02. Alamin Hossain (161-15-7483)03. Md. Khasrur Rahman (161-15-7214)04. Md. Eram Talukder (161-15-7485)05. Ijaz Ahmed Utsa (161-15-7180)

3

What Is Modeling?

• A model is a simplification with a purpose• Use precisely defined notation to describe and simplify a

complex and interesting structure, phenomenon, or relationship

• Real-world examples• The solar system model• Mathematical models

4

What Is Modeling? (cont’d)

• Simplification• Less complex, more accessible

• Varying perspectives• Describe the system from different perspectives• Help developers manage complexity

• Common notation• To facilitate communication• Allows developers to combine their efforts and to work in parallel

5

UML

• Unified Modeling Language• A language for specifying, visualizing, constructing, and documenting the

artifacts of software systems• A set of precise notations• Helps developers create ideas and communicate them

6

UMLThe Basics

Abstraction • A simplification or model of a complex concept, process, or real-world

object• Help people understand something at an appropriate level• Different people would build different abstractions for the same

concept• Highlight the characteristics and behavior of something that is too

complex to understand in its entirety

7

UMLThe Basics

Encapsulation • Highlight the important aspects of an object• Hide the cumbersome internal details of the object• Make the system easier to understand and to reuse• Make a system more extendible

8

UMLThe Basics

Union of all Modeling LanguagesUse case diagramsClass diagramsObject diagramsSequence diagramsCollaboration diagramsStatechart diagramsActivity diagramsComponent diagrams Deployment diagrams….

9

UMLThe Basics

• Object• A particular and finite element in a large model

• Visible or invisible• Persistent or transient

• State: describes characteristics and current condition• Behavior: defines the actions that other objects may perform on the

object• Method: a service or responsibility that an object exposes to other

objects• Each has a unique identifier• Limited responsibility and cooperation

myCar : ToyotaTercel

10

UMLThe Basics

Dependency Association

Aggregation Composition

Relationships between objects

11

Relationships between objectsDependency• Short-term dependency• An object may create another object as part of a method, ask it to

perform some function, and then forget about it

12

Relationships between objectsAssociation

• An object keeps a reference to another object and can call the object’s, methods as it needs them

• An object may receive an object as a parameter to a configuration method and keep a reference to the object

13

Relationships between objectsAggregation

• An object is part of a greater whole• The contained object may participate in more than one aggregation

relationship, and exists independently of the whole

14

Relationships between objectsComposition

• An object is owned by a greater whole• The contained object may not participate in more than one composition

relationship and cannot exist independently of the whole

15

UMLThe Basics• Class

• A group of objects that have something in common• Captures a particular abstraction• Provides a template for object creation• Each objects created from a class is identical in

• The type of data they can hold• The type and number of objects they know about• The logic for any behavior they provide

+attackKenDoll()

-name : String-rank : String#carryingRifle : Boolean

ToySoldier

16

UMLThe Basics

• Class Attributes -Represent the named properties of a UML class

-UML class can have many attributes of different names

-Attributes name is generally a short noun or a noun phrase written in lower Case

first text.

-Attribute decleration may include visility , type

and initial value : +attributesName: type = initial-value

17

UMLThe Basics

Class Operations -Represent named services provided by a UML class

-UML class can have many operations of different names

-Operation name is generally a short verb or a verb phrase written in

lowCase-first text

-Operation may include visibility , parameters and return type:

+opName(param1 : type = initial_value) :return_type

18

UMLThe Basics

Class Visibility -Three levels of class ,attribute and operation visibility:

private(-), available only to the current classProtected(#) , available to the current and inherited classesPublic(+), available to the current and other classes.

19

UMLThe Basics

• Class GeneralizationRepresent a relation between a parent (a more abstract class ) and a child ( a

more specific class)Generally referred to as a “ is -a –kind-of” relationshipChild object may be used instead of parent objects since they share

attributes and operations: the opposite is not true

20

Relationships between Classes

Generalization: an inheritance relationship inheritance between classes interface implementation

Association: a usage relationship Dependency Aggregation Composition

21

Generalization relationships

• Inheritance : class B is a Class A (or class A is extended by class B)

• Realization : class B realizes Class A (or class A is realized by class B)

22

Associational Relationship

• associational (usage) relationships

1. multiplicity(how many are used)

* 0, 1, or more⇒ 1 1 exactly⇒ 2..4 between 2 and 4, inclusive⇒ 3..* 3 or more⇒2. name(what relationship the objects have)

3. navigability(direction)

23

Associational Relationship• Dependency : class A uses class B

• Aggregation : class A has a class B

• Composition : class A owns a class B

24

Multiplicity of associations

One-to One

*each student must carry exactly one ID card

One-to-many

*one rectangle list van contain many rectangles

25

Class diagram example:video store

26

Modeling Software Systems with the UML

• UML enables building a single coherent model that describes a software system from several perspectives• Internal consistency• Distinct views

• Participants can use the same model and speak the same language throughout the development process

27

Modeling Process

1. The developers and customers use the UML to understand the problem from the customer’s point of view

2. The developers use UML to understand the problem from their own point of view

3. The UML model is used as a resource by the implementers of the system

28

Modeling Process (cont’d)

• Requirements gathering• Analysis• Technology selection• Architecture• Design and implementation

29

Design and Implementation

• Design• Use all the results from the previous steps• Create a model of objects that interact to provide the system’s functionality• The last chance to validate the solution

• Implementation• Write the code according to the design

END