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

  • Published on
    09-Jun-2018

  • View
    213

  • Download
    0

Embed Size (px)

Transcript

<ul><li><p>UML (UML Class Diagram) </p></li><li><p>Objectives </p><p> UML . </p><p>2 </p></li><li><p> (Class Diagram) </p><p> , </p><p>3 </p></li><li><p>1. UML: </p><p>4 </p><p>java . awt :: Font or </p><p>java . awt . Font </p><p>plain : Int = 0 { readOnly } bold : Int = 1 { readOnly } name : String style : Int = 0 ... </p><p>getFont ( name : String ) : Font getName () : String ... </p><p>interface Runnable </p><p>run () </p><p>- 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 </p><p>SubclassFoo </p><p>... </p><p>run () ... </p><p>SuperclassFoo or </p><p>SuperClassFoo { abstract } </p><p>- classOrStaticAttribute : Int + publicAttribute : String - privateAttribute assumedPrivateAttribute isInitializedAttribute : Bool = true aCollection : VeggieBurger [ * ] attributeMayLegallyBeNull : String [ 0 .. 1 ] finalConstantAttribute : Int = 5 { readOnly } / derivedAttribute </p><p>+ 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 } </p><p>3 common compartments </p><p>1 . classifier name </p><p>2 . attributes </p><p>3 . operations </p><p>interface implementation and subclassing </p><p>Fruit </p><p>... </p><p>... </p><p>PurchaseOrder </p><p>... </p><p>... </p><p>1 </p><p>association with multiplicities </p><p>dependency </p><p>officially in UML , the top format is used to distinguish the package name from the class name </p><p>unofficially , the second alternative is common </p><p>order </p><p>an interface shown with a keyword </p></li><li><p>2. : </p><p> (DCD: Design Class Diagram) </p><p>5 </p><p>Register </p><p>... </p><p>endSale () enterItem (...) makePayment (...) </p><p>Sale </p><p>time isComplete : Boolean / total </p><p>makeLineItem (...) </p><p>Register </p><p>... </p><p>Sale </p><p>time isComplete : Boolean / total </p><p>Captures </p><p>1 </p><p>1 1 Domain Model </p><p>conceptual perspective </p><p>Design Model </p><p>DCD ; software perspective </p><p>currentSale </p></li><li><p>3. : </p><p> (classifier) </p><p> ) , , , </p><p>6 </p></li><li><p>4. 1: </p><p> (structural property) </p><p> currentSale:Sale (property text) </p><p> : = {-} </p><p> private . </p><p>7 </p><p>Register </p><p>... </p><p>... </p><p>Sale </p><p>... </p><p>... </p><p>1 </p><p>Register </p><p>currentSale : Sale </p><p>... </p><p>Sale </p><p>... </p><p>... </p><p>Register Sale </p><p>Register Sale </p><p>Register Sale currentSale </p><p>Register </p><p>currentSale : Sale </p><p>... </p><p>Sale </p><p>... </p><p>... </p><p>1 . </p><p>currentSale </p></li><li><p>4. 2: </p><p>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</p><p>Register</p><p>id: Int</p><p>...</p><p>Sale</p><p>time: DateTime</p><p>...</p><p>1</p><p>currentSale</p><p>Register</p><p>id : Int</p><p>Sale</p><p>time : DateTimeCaptures-current-sale1 1UP Domain Model</p><p>conceptual perspective</p><p>UP Design ModelDCD</p><p>software perspective</p><p>8 </p><p> vs. DCD </p><p> (rolename) : </p></li><li><p>4. 3: </p><p>Register</p><p>id: Int</p><p>...</p><p>Sale</p><p>time: DateTime</p><p>...</p><p>1applying the guideline to show attributes as attribute text versus as association lines</p><p>Store</p><p>address: Addressphone: PhoneNumber</p><p>...</p><p>1Register has THREE attributes:1. id2. currentSale3. location</p><p>currentSale</p><p>location</p><p>9 </p><p> (Data Type) </p><p> ) Boolean, Date, Number, Character, String, Time, Address, Color, Geometrics(Point, Rectangle), Phone Number, SSN, UPC, ZIP, </p><p> , . </p><p>public class Register { private int id; private Store location; private Sale currentSale; } </p></li><li><p>4. 3: </p><p> {ordered} {ordered, List} </p><p>notice that an association end can optionally also have a property string such as {ordered, List}</p><p>Sale</p><p>time: DateTime</p><p>...</p><p>SalesLineItem</p><p>...</p><p>...</p><p>1..*lineItems</p><p>{ordered, List}</p><p>Sale</p><p>time: DateTimelineItems : SalesLineItem [1..*] orlineItems : SalesLineItem [1..*] {ordered}</p><p>...</p><p>SalesLineItem</p><p>...</p><p>...</p><p>Two ways to show a collection attribute</p><p>10 </p><p>public class Sale { private DateTime time; private List lineItems = new ArrayList; } </p></li><li><p>5. : , , , </p><p> , </p><p> UML : {} . </p><p> = UML </p><p>11 </p><p>Register </p><p>... </p><p>endSale () enterItem ( id , qty ) makeNewSale () makePayment ( cashTendered ) </p><p>method // pseudo - code or a specific language is OK public void enterItem ( id , qty ) { ProductDescription desc = catalog . getProductDescription ( id ) ; sale . makeLineItem ( desc , qty ) ; } </p></li><li><p>6. 1 </p><p> (} : {} </p><p> public </p><p> 1) +getPlayer(name: String) : Player {exception IOException} Java public Player getPlayer(String name) throws IOException </p><p> 2) +getPlayer(name: String) : Player {abstract} C++ public: virtual Player getPlayer(String name) </p><p> UML </p><p>12 </p></li><li><p>6. 2 </p><p> DCD </p><p> Create </p><p> C++, Java new </p><p> (setter, getter ) </p><p> DCD </p><p> N 2N </p><p>13 </p></li><li><p>7. UML (Keyword) </p><p> UML ? </p><p> UML </p><p> . </p><p> . </p><p>{abstract} . </p><p>{ordered} </p><p>14 </p></li><li><p>8. , , </p><p> UML </p><p> , , ) , </p><p> . </p><p> UML </p><p> {-} </p><p>15 </p><p>stereotype Authorship </p><p>author : String status : String </p><p>UML extension relationship to a basic UML metamodel term Element </p><p>authorship author = craig status = tested </p><p>metaclass Element </p><p>... </p><p>authorship Square </p><p>... </p><p>a tool will probably allow a popup to fill in the tag values , once an element has been stereotyped with authorship </p></li><li><p>9. UML </p><p> Property? . ) : UML </p><p> {name1=value,name2=value2} </p><p> {abstract,visibility=public} </p><p> {abstract} == {abstract=true} </p><p>16 </p></li><li><p>10. , , </p><p> Superclass </p><p> : </p><p> DCD : </p><p> {leaf} </p><p> {abstract} </p><p>17 </p><p>Polygon </p><p> Rectangle </p><p>Polygon {abstract} </p><p> Rectangle </p></li><li><p>11. </p><p> , </p><p> (, , UC) , . </p><p> . </p><p> (coupling) </p><p> : A B . </p><p> A B </p><p> A B () </p><p> A </p><p> B A (/ ) </p><p> , , </p><p> , , , </p><p>18 </p></li><li><p>SalesLineItem</p><p>...</p><p>...</p><p>ProductDescription</p><p>...</p><p>...</p><p>1..*lineItems</p><p>Sale</p><p>...</p><p>updatePriceFor( ProductDescription )...</p><p>the Sale has parameter visibility to a ProductDescription, and thus some kind of dependency</p><p>System</p><p>...</p><p>runFinalization()...</p><p>Foo</p><p>...</p><p>doX()...</p><p>the doX method invokes the runFinalization static method, and thus has a dependency on the System class</p><p>19 </p><p>public class Sale { public void updatePriceFor(ProductDescription desc) { Money basePrice = desc.getPrice(); // } private SalesLineItem lineitems; // } </p><p>public class Foo { public void doX() { System.runFinalization(); // } // } </p></li><li><p>20 </p><p>call Window </p><p>a dependency on calling on operations of the operations of a Clock </p><p>Clock </p><p>getTime () ... </p><p>create A </p><p>a dependency that A objects create B objects </p><p>B </p><p>... </p></li><li><p>12. </p><p> UML (interface realization) </p><p> , </p><p>21 </p><p>interface Timer </p><p>getTime () </p><p>Clock 1 </p><p>... </p><p>getTime () ... lollipop notation indicates Clock 3 implements </p><p>and provides the Timer interface to clients </p><p>Timer is a provided interface </p><p>Timer </p><p>Clock 3 </p><p>... </p><p>getTime () ... </p><p>Window 2 </p><p>Window 3 </p><p>dependency line notation </p><p>Window 2 has a dependency on the Timer interface when it collaborates with a Clock 2 object </p><p>socket line notation </p><p>Window 3 has a dependency on the Timer interface when it collaborates with a Clock 3 object </p><p>Window 1 Timer </p><p>socket line notation </p><p>Window 1 uses the Timer interface </p><p>it has a required interface </p><p>Clock 2 </p><p>... </p><p>getTime () ... </p><p>Clock 1 implements and provides the Timer interface </p><p>Timer </p></li><li><p>13. (aggregation) (composition) </p><p> (aggregation) </p><p> , . </p><p> (composition) </p><p> Square Board . </p><p> . </p><p> . , . </p><p>Finger0..7</p><p>Hand</p><p>composition</p><p>1</p><p>Square40</p><p>Board1</p><p>SalesLineItem1..*Sale1</p><p>composition means -a part instance (Square) can only be part of one composite (Board) at a time </p><p>-the composite has sole responsibility for management of its parts, especially creation and deletion</p><p>22 </p></li><li><p>14. </p><p> UML (constraints) </p><p> UML </p><p> {} </p><p> 3 </p><p>23 </p><p>Stack </p><p>size : Integer { size &gt; = 0 } </p><p>push ( element ) pop () : Object </p><p>three ways to show UML constraints </p><p>{ post condition : new size = old size + 1 } </p><p>{ post condition : new size = old size 1 } </p></li><li><p>15. </p><p> (qualified association) </p><p> , (qualifier) . </p><p> : </p><p>ProductCatalog</p><p>ProductDescriptionitemID</p><p>Contains</p><p>ProductCatalog</p><p>ProductDescription</p><p>Contains</p><p>1..*</p><p>multiplicity reduced to 1</p><p>(a)</p><p>(b)</p><p>qualifier</p><p>1</p><p>11</p><p>24 </p></li><li><p>16. </p><p> (association class) </p><p> ) Employment Company Person , salary startDate </p><p>salarystartDate</p><p>Employment</p><p>EmploysCompany Person**</p><p>a person may have employment with several companies</p><p>25 </p></li><li><p>17. Singleton </p><p> Singleton </p><p>26 </p><p> 1 ServicesFactory </p><p>instance : ServicesFactory </p><p>accountingAdapter : IAccountingAdapter inventoryAdapter : IInventoryAdapter taxCalculatorAdapter : ITaxCalculatorAdapter </p><p>getInstance () : ServicesFactory </p><p>getAccountingAdapter () : IAccountingAdapter getInventoryAdapter () : IInventoryAdapter getTaxCalculatorAdapter () : ITaxCalculatorAdapter ... </p><p>UML notation : in a class box , an underlined attribute or method indicates a static ( class level ) member , rather than an instance member </p><p>UML notation : this ' 1 ' can optionally be used to indicate that only one instance will be created ( a singleton ) </p></li><li><p>18. </p><p> (template class) </p><p> C++, Java </p><p> collection ) Square ArrayList ArrayList </p><p>27 </p><p>public class Board { private List squares = new ArrayList // } </p><p>interface List </p><p>clear () ... </p><p>K parameterized or template interfaces and classes </p><p>K is a template parameter </p><p>anonymous class with template binding complete </p><p>Board </p><p>squares : List &lt; K Square &gt; or squares : List &lt; Square &gt; ... </p><p>ArrayList &lt; T Square &gt; </p><p>clear () ... </p><p>the attribute type may be expressed in official UML , with the template binding syntax requiring an arrow or in another language , such as Java </p><p>ArrayList </p><p>elements : T [*] ... </p><p>clear () ... </p><p>T </p><p>for example , the elements attribute is an array of type T , parameterized and bound before actual use . </p><p>there is a chance the UML 2 arrow symbol will eventually be replaced with something else e . g . , = </p></li><li><p>19. </p><p> , , UML </p><p> ) , </p><p>DataAccessObject</p><p>id : Int...</p><p>doX()...</p><p>exceptions thrownDatabaseExceptionIOException</p><p>responsibilitiesserialize and write objectsread and deserialize objects...</p><p>28 </p></li><li><p>20. </p><p> (thread) </p><p>29 </p><p>interface Runnable </p><p>run () </p><p>Clock </p><p>... </p><p>run () ... </p><p>active class </p></li><li><p>21. vs. </p><p> ? </p><p> . </p><p> Agile </p><p> ) 10 10 , </p><p>30 </p><p>: Register : Sale </p><p>makePayment ( cashTendered ) </p><p>makePayment ( cashTendered ) </p><p>Register </p><p>... </p><p>makePayment ( ) ... </p><p>Sale </p><p>... </p><p>makePayment ( ) ... </p><p>1 </p><p>currentSale </p><p>messages in interaction diagrams indicate operations in the class diagrams classes </p><p>identified in the interaction diagrams are declared in the class diagrams </p><p>UML (UML Class Diagram)Objectives1. UML: 2. : 3. : 4. 1: 4. 2: 4. 3: 4. 3: 5. : , , , 6. 16. 27. UML (Keyword)8. , , 9. UML 10. , , 11. 12. 13. (aggregation) (composition) 14. 15. 16. 17. Singleton 18. 19. 20. 21. vs. </p></li></ul>