UML 클래스 다이어그램 표기법 - ?· 1. UML 적용하기: 클래스 다이어그램의 일반적…

Embed Size (px)

Text of UML 클래스 다이어그램 표기법 - ?· 1. UML 적용하기: 클래스 다이어그램의...

  • UML (UML Class Diagram)

  • Objectives

    UML .

    2

  • (Class Diagram)

    ,

    3

  • 1. UML:

    4

    java . awt :: Font or

    java . awt . Font

    plain : Int = 0 { readOnly } bold : Int = 1 { readOnly } name : String style : Int = 0 ...

    getFont ( name : String ) : Font getName () : String ...

    interface Runnable

    run ()

    - ellipsis means there may be elements , but not shown - a blank compartment officially means unknown but as a convention will be used to mean no members

    SubclassFoo

    ...

    run () ...

    SuperclassFoo or

    SuperClassFoo { abstract }

    - classOrStaticAttribute : Int + publicAttribute : String - privateAttribute assumedPrivateAttribute isInitializedAttribute : Bool = true aCollection : VeggieBurger [ * ] attributeMayLegallyBeNull : String [ 0 .. 1 ] finalConstantAttribute : Int = 5 { readOnly } / derivedAttribute

    + classOrStaticMethod() + publicMethod() assumedPublicMethod() - privateMethod() # protectedMethod() ~ packageVisibleMethod() constructor SuperclassFoo (Long ) methodWithParms(param1:String, param2:Float) methodReturnsSomething(): VeggieBurger methodThrowsException () { exception IOException } abstractMethod () abstractMethod 2 () { abstract } // alternate finalMethod () { leaf } // no override in subclass synchronizedMethod () { guarded }

    3 common compartments

    1 . classifier name

    2 . attributes

    3 . operations

    interface implementation and subclassing

    Fruit

    ...

    ...

    PurchaseOrder

    ...

    ...

    1

    association with multiplicities

    dependency

    officially in UML , the top format is used to distinguish the package name from the class name

    unofficially , the second alternative is common

    order

    an interface shown with a keyword

  • 2. :

    (DCD: Design Class Diagram)

    5

    Register

    ...

    endSale () enterItem (...) makePayment (...)

    Sale

    time isComplete : Boolean / total

    makeLineItem (...)

    Register

    ...

    Sale

    time isComplete : Boolean / total

    Captures

    1

    1 1 Domain Model

    conceptual perspective

    Design Model

    DCD ; software perspective

    currentSale

  • 3. :

    (classifier)

    ) , , ,

    6

  • 4. 1:

    (structural property)

    currentSale:Sale (property text)

    : = {-}

    private .

    7

    Register

    ...

    ...

    Sale

    ...

    ...

    1

    Register

    currentSale : Sale

    ...

    Sale

    ...

    ...

    Register Sale

    Register Sale

    Register Sale currentSale

    Register

    currentSale : Sale

    ...

    Sale

    ...

    ...

    1 .

    currentSale

  • 4. 2:

    the association name, common when drawing a domain model, is often excluded (though still legal) when using class diagrams for a software perspective in a DCD

    Register

    id: Int

    ...

    Sale

    time: DateTime

    ...

    1

    currentSale

    Register

    id : Int

    Sale

    time : DateTimeCaptures-current-sale1 1UP Domain Model

    conceptual perspective

    UP Design ModelDCD

    software perspective

    8

    vs. DCD

    (rolename) :

  • 4. 3:

    Register

    id: Int

    ...

    Sale

    time: DateTime

    ...

    1applying the guideline to show attributes as attribute text versus as association lines

    Store

    address: Addressphone: PhoneNumber

    ...

    1Register has THREE attributes:1. id2. currentSale3. location

    currentSale

    location

    9

    (Data Type)

    ) Boolean, Date, Number, Character, String, Time, Address, Color, Geometrics(Point, Rectangle), Phone Number, SSN, UPC, ZIP,

    , .

    public class Register { private int id; private Store location; private Sale currentSale; }

  • 4. 3:

    {ordered} {ordered, List}

    notice that an association end can optionally also have a property string such as {ordered, List}

    Sale

    time: DateTime

    ...

    SalesLineItem

    ...

    ...

    1..*lineItems

    {ordered, List}

    Sale

    time: DateTimelineItems : SalesLineItem [1..*] orlineItems : SalesLineItem [1..*] {ordered}

    ...

    SalesLineItem

    ...

    ...

    Two ways to show a collection attribute

    10

    public class Sale { private DateTime time; private List lineItems = new ArrayList; }

  • 5. : , , ,

    ,

    UML : {} .

    = UML

    11

    Register

    ...

    endSale () enterItem ( id , qty ) makeNewSale () makePayment ( cashTendered )

    method // pseudo - code or a specific language is OK public void enterItem ( id , qty ) { ProductDescription desc = catalog . getProductDescription ( id ) ; sale . makeLineItem ( desc , qty ) ; }

  • 6. 1

    (} : {}

    public

    1) +getPlayer(name: String) : Player {exception IOException} Java public Player getPlayer(String name) throws IOException

    2) +getPlayer(name: String) : Player {abstract} C++ public: virtual Player getPlayer(String name)

    UML

    12

  • 6. 2

    DCD

    Create

    C++, Java new

    (setter, getter )

    DCD

    N 2N

    13

  • 7. UML (Keyword)

    UML ?

    UML

    .

    .

    {abstract} .

    {ordered}

    14

  • 8. , ,

    UML

    , , ) ,

    .

    UML

    {-}

    15

    stereotype Authorship

    author : String status : String

    UML extension relationship to a basic UML metamodel term Element

    authorship author = craig status = tested

    metaclass Element

    ...

    authorship Square

    ...

    a tool will probably allow a popup to fill in the tag values , once an element has been stereotyped with authorship

  • 9. UML

    Property? . ) : UML

    {name1=value,name2=value2}

    {abstract,visibility=public}

    {abstract} == {abstract=true}

    16

  • 10. , ,

    Superclass

    :

    DCD :

    {leaf}

    {abstract}

    17

    Polygon

    Rectangle

    Polygon {abstract}

    Rectangle

  • 11.

    ,

    (, , UC) , .

    .

    (coupling)

    : A B .

    A B

    A B ()

    A

    B A (/ )

    , ,

    , , ,

    18

  • SalesLineItem

    ...

    ...

    ProductDescription

    ...

    ...

    1..*lineItems

    Sale

    ...

    updatePriceFor( ProductDescription )...

    the Sale has parameter visibility to a ProductDescription, and thus some kind of dependency

    System

    ...

    runFinalization()...

    Foo

    ...

    doX()...

    the doX method invokes the runFinalization static method, and thus has a dependency on the System class

    19

    public class Sale { public void updatePriceFor(ProductDescription desc) { Money basePrice = desc.getPrice(); // } private SalesLineItem lineitems; // }

    public class Foo { public void doX() { System.runFinalization(); // } // }

  • 20

    call Window

    a dependency on calling on operations of the operations of a Clock

    Clock

    getTime () ...

    create A

    a dependency that A objects create B objects

    B

    ...

  • 12.

    UML (interface realization)

    ,

    21

    interface Timer

    getTime ()

    Clock 1

    ...

    getTime () ... lollipop notation indicates Clock 3 implements

    and provides the Timer interface to clients

    Timer is a provided interface

    Timer

    Clock 3

    ...

    getTime () ...

    Window 2

    Window 3

    dependency line notation

    Window 2 has a dependency on the Timer interface when it collaborates with a Clock 2 object

    socket line notation

    Window 3 has a dependency on the Timer interface when it collaborates with a Clock 3 object

    Window 1 Timer

    socket line notation

    Window 1 uses the Timer interface

    it has a required interface

    Clock 2

    ...

    getTime () ...

    Clock 1 implements and provides the Timer interface

    Timer

  • 13. (aggregation) (composition)

    (aggregation)

    , .

    (composition)

    Square Board .

    .

    . , .

    Finger0..7

    Hand

    composition

    1

    Square40

    Board1

    SalesLineItem1..*Sale1

    composition means -a part instance (Square) can only be part of one composite (Board) at a time

    -the composite has sole responsibility for management of its parts, especially creation and deletion

    22

  • 14.

    UML (constraints)

    UML

    {}

    3

    23

    Stack

    size : Integer { size > = 0 }

    push ( element ) pop () : Object

    three ways to show UML constraints

    { post condition : new size = old size + 1 }

    {