Chapter 16 UML类图 ●●●●● ●●●● ●●。●●
Chapter 16 UML类图
●●●●● ●●●● 简介 ●●● ●●● ●●●● ●UML用类图表示类,接口及其关联 类图用于静态对象建模 类图和概念图之间的关系 Domain model Register 1 Captures conceptual perspective is Complete: Boolean /total Register Sale Design Model time is Complete: Boolean DCD: software end saleo currentSale/total perspective enterItem(.) make Payment(.) makeLineltem()
简介 ⚫ UML用类图表示类,接口及其关联 ⚫ 类图用于静态对象建模 ⚫ 类图和概念图之间的关系 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
表示法(文本格式) SuperclassFoo used to distinguish the package name from the class name ●●●●● SuperclassFoo( abstract ●●●● unofficially, the second alternative class OrStaticAttribute: Int Is common ●●● ●●● 3 common compartments privateAttribute ●●●● ssumed Private Attribute 1. classifier name Initialized Attribute: Bool true aCollection: VeggieBurger[ o java. awt: Font 2. attributes attribute Legally BeNull String [0.11 finalConstantAttribute: Int=5(readonly 1 java. awt. Font /derivedAttribute 3. operations plain: Int =0 readonly classorStaticMethodo bold: Int =1 readOnly y publicMethodo assumedPublicMethodo style: Int =0 an interface protectedMethodo keyword getFont(name: String): Font packageVisibleMethod getName0: String methodWithParms(parm1: String parma: Float methodReturns Something(: Veggie Burger Interface》 methodThrows Exception( exception IOException Runnable abstractMethodo abstractMethod20 abstract) //alternate runo finalMethodo( leaf)//no override in subclass ynchronizedMethodoi guarded y interface subclassing Subclass Foo Purchaseorder association with ellipsis".means there may be elements, but not shown multiplicities blank compartment officially means "unknown but as a convention will be used to mean "no members
表示法(文本格式) 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(parm1 : String, parm2 : Float) methodReturnsSomething() : VeggieBurger methodThrowsException() {exception IOException} abstractMethod() abstractMethod2() { 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
图形格式 ●●●●● ●●●● ●●● (Rational Software Modeler) ●●● ●●●● AC卫ass 口 privateAttribute o publicAttribute 工 nteger o staticattribute ● lOAn10 peration St112 o abstractOperation (
图形格式 (Rational Software Modeler)
●●●●● ●●●● UML中的类型 ●●● ●●● ●●●● 类 接 ●枚举 ●数据类型 inter face》 enuunerat1on》 Person Iterator 运年级 o name: String o一年级 e haslEt ( o二年级 o三年级 (primitive) 9 Date
UML中的类型 ⚫ 类 ⚫ 接口 ⚫ 枚举 ⚫ 数据类型