MELJUN CORTES Java Lecture UML

37
Introduction to the Introduction to the Unified Modeling Unified Modeling Language Language Java Fundamentals and Object- Java Fundamentals and Object- Oriented Programming Oriented Programming The Complete Java Boot Camp The Complete Java Boot Camp MELJUN CORTES MELJUN CORTES MELJUN CORTES MELJUN CORTES

description

MELJUN CORTES Java Lecture UML

Transcript of MELJUN CORTES Java Lecture UML

Page 1: MELJUN CORTES Java Lecture UML

Introduction to theIntroduction to the

Unified Modeling Unified Modeling LanguageLanguage

Java Fundamentals and Object-Oriented Java Fundamentals and Object-Oriented ProgrammingProgramming

The Complete Java Boot CampThe Complete Java Boot Camp

MELJUN CORTESMELJUN CORTES

MELJUN CORTESMELJUN CORTES

Page 2: MELJUN CORTES Java Lecture UML

ContentsContents

I.I. What is UML?What is UML?

II.II. Class DiagramsClass Diagrams

III.III.Sequence DiagramsSequence Diagrams

IV.IV.OthersOthers

Page 3: MELJUN CORTES Java Lecture UML

ReferenceReference

UML DistilledUML Distilled Martin FowlerMartin Fowler practical, no-frills practical, no-frills

approach to UMLapproach to UML

Page 4: MELJUN CORTES Java Lecture UML

ReferenceReference

Agile Modeling Hope Agile Modeling Hope PagePage ““Effective Practices Effective Practices

for Modeling and for Modeling and Documentation”Documentation”

Scott AmblerScott Ambler http://http://

www.agilemodeling.cwww.agilemodeling.comom

Page 5: MELJUN CORTES Java Lecture UML

What is UML?What is UML?

Consolidation of the various graphical-Consolidation of the various graphical-modeling methods existent during the late modeling methods existent during the late '80's and early '90's (around 5000)'80's and early '90's (around 5000)

Created by Booch, Rumbaugh, Jacobson Created by Booch, Rumbaugh, Jacobson (“the three amigos”)(“the three amigos”)

Open standard managed by the Open Open standard managed by the Open Management Group (OMG)Management Group (OMG)

Currently at version 2.0, describing about Currently at version 2.0, describing about 20 types of diagrams20 types of diagrams

Page 6: MELJUN CORTES Java Lecture UML

What is UML?What is UML?

Three ways of using UML:Three ways of using UML: for sketchingfor sketching for blue printingfor blue printing

forward engineering reverse engineering

as programming languageas programming language “model-driven architecture” / “executable UML”

Page 7: MELJUN CORTES Java Lecture UML

Class DiagramClass Diagram

Page 8: MELJUN CORTES Java Lecture UML

Class DiagramClass Diagram

primary means of describing classes and primary means of describing classes and the the static relationships between themstatic relationships between them

Page 9: MELJUN CORTES Java Lecture UML

Class DiagramClass Diagram

Describing a Describing a classclass compartmentscompartments

class name attributes operations

Page 10: MELJUN CORTES Java Lecture UML

Class DiagramClass Diagram

Describing a Describing a classclass

access levelsaccess levels

private: -

protected: #

public: +

Page 11: MELJUN CORTES Java Lecture UML

Class DiagramClass Diagram

Describing an Describing an interfaceinterface different tools / different tools /

books will render an books will render an interface differentlyinterface differently

most texts will most texts will render it same as render it same as class but without class but without attribute attribute compartmentcompartment

Page 12: MELJUN CORTES Java Lecture UML

Class DiagramClass Diagram

RelationshipsRelationships NavigabilityNavigability Multiplicity / Multiplicity /

CardinalityCardinality AssociationAssociation

Aggregation Composition

DependencyDependency

Inheritance / Inheritance / GeneralizationGeneralization

RealizationRealization

OthersOthers replacing attributes replacing attributes

with named with named associationsassociations

stereotypesstereotypes

Page 13: MELJUN CORTES Java Lecture UML

Class DiagramClass Diagram

NavigabilityNavigability arrowheadarrowhead

one-way navigability, the side with the arrowhead cannot see the other

no arrowheadno arrowhead two-way navigability,

both sides can see each other

Page 14: MELJUN CORTES Java Lecture UML

Class DiagramClass Diagram

Multiplicity / Multiplicity / CardinalityCardinality number of possible number of possible

occurrences of an occurrences of an elementelement

0..*, *, 1, 1..*0..*, *, 1, 1..*

Page 15: MELJUN CORTES Java Lecture UML

Class DiagramClass Diagram

AggregationAggregation the contained the contained

element can exist element can exist even if the even if the containing object no containing object no longer existslonger exists

Page 16: MELJUN CORTES Java Lecture UML

Class DiagramClass Diagram

CompositionComposition the enclosed the enclosed

element cannot element cannot exist without the exist without the containing elementcontaining element

Page 17: MELJUN CORTES Java Lecture UML

Class DiagramClass Diagram

DependencyDependency when an element is when an element is

needed by a class needed by a class but the element is but the element is not and aggregate not and aggregate of the class (such of the class (such as a parameter)as a parameter)

Page 18: MELJUN CORTES Java Lecture UML

Class DiagramClass Diagram

Inheritance / Inheritance / GeneralizationGeneralization empty-triangle empty-triangle

arrowhead with arrowhead with solid linesolid line

Page 19: MELJUN CORTES Java Lecture UML

Class DiagramClass Diagram

RealizationRealization when a class when a class

implements an implements an interfaceinterface

empty triangle empty triangle arrowhead with arrowhead with dashed linedashed line

Page 20: MELJUN CORTES Java Lecture UML

Class DiagramClass Diagram

replacing attributes replacing attributes with named with named associationsassociations both can represent both can represent

a propertya property to avoid clutter, if to avoid clutter, if

you use one don't you use one don't use the otheruse the other

Page 21: MELJUN CORTES Java Lecture UML

Class DiagramClass Diagram

StereotypeStereotype used to create your used to create your

own special kinds of own special kinds of classesclasses

Page 22: MELJUN CORTES Java Lecture UML

Sequence DiagramSequence Diagram

Page 23: MELJUN CORTES Java Lecture UML

Sequence DiagramSequence Diagram

used to describe how used to describe how objectsobjects interact with interact with each other and the sequencing of these each other and the sequencing of these interactionsinteractions

Page 24: MELJUN CORTES Java Lecture UML

Sequence DiagramSequence Diagram

Top boxes represent Top boxes represent objects, not classes. You objects, not classes. You may optionally add may optionally add “:class” to the name if “:class” to the name if desired.desired.

Vertical lines represent Vertical lines represent the objects “life line”, or the objects “life line”, or existence.existence.

Broken lifeline indicates Broken lifeline indicates the object is inactive, a the object is inactive, a rectangle indicates the rectangle indicates the object is active.object is active.

Page 25: MELJUN CORTES Java Lecture UML

Sequence DiagramSequence Diagram arrows with solid lines arrows with solid lines

represent messages represent messages being sent.being sent.

arrows with dashed lines arrows with dashed lines (optional if synchronous) (optional if synchronous) represent method return. represent method return. (May label arrow with (May label arrow with name/type of returned name/type of returned object).object).

Page 26: MELJUN CORTES Java Lecture UML

Sequence DiagramSequence Diagram

Sending object’s class must Sending object’s class must have:have:

An association of some An association of some sort with the receiving sort with the receiving objects class.objects class.

The receiver-side class’s The receiver-side class’s “role” must be the same “role” must be the same as the name of the as the name of the receiving object.receiving object.

Page 27: MELJUN CORTES Java Lecture UML

Sequence DiagramSequence Diagram

Object creationObject creation The new instance The new instance

appears at end of appears at end of creation message creation message arrowarrow

Page 28: MELJUN CORTES Java Lecture UML

Sequence DiagramSequence Diagram

Object DestructionObject Destruction accomplished by accomplished by

terminating the terminating the lifeline with a large Xlifeline with a large X

Page 29: MELJUN CORTES Java Lecture UML

Sequence DiagramSequence Diagram

Sequence diagrams Sequence diagrams can begin with a can begin with a useruser

Page 30: MELJUN CORTES Java Lecture UML

Sequence DiagramSequence Diagram

System Sequence System Sequence DiagramDiagram sequence diagram sequence diagram

describing describing interaction between interaction between user and system as user and system as a blackboxa blackbox

Page 31: MELJUN CORTES Java Lecture UML

Other UML DiagramsOther UML Diagrams

Use CaseUse Case CollaborationCollaboration ActivityActivity ComponentComponent DeploymentDeployment

Page 32: MELJUN CORTES Java Lecture UML

Use Case DiagramUse Case Diagram

Used to provide Used to provide overview of the overview of the usecases of the usecases of the systemsystem

Page 33: MELJUN CORTES Java Lecture UML

Collaboration DiagramCollaboration Diagram

Similar to sequence diagram but Similar to sequence diagram but does not plot messages against does not plot messages against timetime

Page 34: MELJUN CORTES Java Lecture UML

Activity DiagramActivity Diagram

typically used for typically used for business process business process modeling, for modeling, for modeling the logic modeling the logic captured by a captured by a single use case or single use case or usage scenario, or usage scenario, or for modeling the for modeling the detailed logic of a detailed logic of a business rulebusiness rule

Page 35: MELJUN CORTES Java Lecture UML

State Machine DiagramState Machine Diagram

Depicting the move from one state to Depicting the move from one state to another of a complex objectanother of a complex object

Page 36: MELJUN CORTES Java Lecture UML

Component DiagramComponent Diagram

High-level representation of system High-level representation of system componentscomponents

Page 37: MELJUN CORTES Java Lecture UML

Deployment DiagramDeployment Diagram

Similar to Similar to component diagram component diagram but includes but includes hardware “nodes”hardware “nodes”