the unified modelling lanage (uml)
TRANSCRIPT
The Unified Modelling Language (UML)
อาจารย์สมเกียรติ ช่อเหมือน ([email protected])สาขาวิชาวิศวกรรมซอฟต์แวร์ คณะวิทยาศาสตร์และเทคโนโลยี
The Unified Modelling Language (UML)
• An introduction to UMLUML Class DiagramsUML SyntaxUML Package DiagramsUML Object diagramsUML Sequence Diagrams
UML (Unified Modelling Language)
• การสร้างแบบจ าลองซอฟต์แวร์ ในรูปของสัญลักษณ์ • เพื่อใช้ในการอธิบายระเบียบวิธีการ • เข้าใจล าดับขั้นตอนในการท างานให้บรรลุผล• จัดล าดับของกิจกรรมเพื่อรวบรวมความต้องการของผู้ใช้• กระบวนการเขียน Diagram โดยใช้ สัญลักษณ์ในการออกแบบซอฟต์แวร์
น าเสนอ และตกลงร่วมกัน• ใช้แผนภาพประกอบเพื่อช่วยให้เข้าใจได้ง่าย และอธิบายข้อมูลทางเทคนิคให้
ถูกต้องตรงกันและชัดเจนขึ้น• น าไปใช้ในกระบวนต่อไปของการพัฒนาซอฟต์แวร์ได้• ไม่ใช้วิธีการ แต่เป็นสิ่งที่น าไปใช้ช่วยให้สามารถออกแบบและน าไปใช้ไดอ้ย่าง
ถูกต้อง ด้วยการสร้างแผนภาพ เพื่อเป็นแนวทางที่เหมาะสมตามความต้องการ
Class diagrams
• แผนภาพพ้ืนฐานของแนวคิดเชิงวัตถุ
• แสดงรายละเอียดของสิ่งต่างๆ
• แสดงความเกี่ยวข้องของสิ่งต่างๆ
• แสดงสถาปัตยกรรมของระบบ
Class diagrams
• Class ชั้นประกอบด้วย– ชื่อไม่ซ้ ากัน (*ขึ้นต้นด้วยตัวพิมพ์ใหญ)่– รายการแอตทริบิวต์– รายการของวิธีการ
• การมองเห็นและการเข้าถึงจากภายนอก (visibility modifiers)– private Attributes– public methods
• ทราบถึงข้อมูลที่สนใจและสามารถตัดสว่นที่ไม่สนใจออกได้• บาง Class จะเรียกใช้งาน Classอื่น ๆ • ความสัมพันธ์เหล่านี้จะแสดงโดยลูกศร
Class diagrams
• Classes– - attributes– - operations– - visibility
• Relationships– - navigability– - multiplicity– - dependency– - aggregation– - composition
• Generalization / specialization– - inheritance– - interfaces
• Keywords• Notes and Comments
UML Syntax
• Visibility‘+’ public
‘-’ private
‘#’ protected
‘~’ package
• Multiplicity is one‘n’ exactly n
‘*’ zero or more
‘m..‘n’ between m and n
UML Syntax
• Visibility‘+’ public
‘-’ private
‘#’ protected
‘~’ package
• Multiplicity is one‘n’ exactly n
‘*’ zero or more
‘m..‘n’ between m and n
Examples of attributes
• visibility name (par1 : type1, par2 : type2): returntype
- custRef : int [1]
# itemCodes : String [1..*]
validCard : boolean
Examples of method
• + addName (newName : String) : boolean
relationships between classes
• ‘Association’
multiplicity
‘source’ class points to the ‘target’
Relationships between classes
• The diagram below shows this information
• All class names begin in uppercase• attribute and method names begin in lowercase.
• class ItemForSale describes a single item• ‘listOfItems’ list of zero or more individual objects
Types of Association
• Dependency
• Simple association
• Bidirectional association
• Aggregation and
• Composition
Inheritance
การ คลาส A สืบทอดมาจากคลาส B
Interfaces
• implemented by Publication• required by CashTill
<<realizes>>
“ball and socket” in UML2
Notes
elements of UML Class Diagram notation
elements of UML Class Diagram notation
Package Diagrams
Package Naming
• package names are normally in lowercase• local individual projects packages
– Mysystem– mysystem.interface– mysystem.engine– mysystem.engine.util– mysystem.database
• based on URL
Package Diagram
• Dependency arrows have been drawn to highlight relationships betweenpackages. When more thought has been put into determining these relationships theymay turn out to be associations
UML Object Diagrams
• objectName : ClassName
• attribute = value
Sequence Diagrams
actions taking place
Sequence Diagrams
• Selection and Iteration– The logic of a scenario often depends on selection (‘if’) and
iteration (loops).– There is a notation (‘interaction frames’) which allow ifs and
loops to be represented in sequencediagrams however these tend to make the diagrams cluttered.
– Sequence diagrams are generally best used for illustrating particular cases, with the full refinement reserved for the implementation code.
UML notation (สัญลักษณ์)
UML
https://www.google.co.th/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=0ahUKEwi-wsj0kqbLAhXHCo4KHRWzDdcQjRwIBw&url=http%3A%2F%2Fwww.sedris.org%2Fdm_notn.htm&psig=AFQjCNHYZn1cgpz8DvGn-gXSSomANAKAPQ&ust=1457150162826343
สัญลักษณ์ที่ใช้ในการเขียน UML
UML class-object
Elephant
e1 e2
UML
new
สรุป
• UML เป็นภาษาที่ใช้ก าหนดรายละเอียดโดยใช้โมเดลด้านซอฟต์แวร์ เพื่อช่วยให้สามารถท างานร่วมกันได้ โดยยึดรูปแบบที่วิเคราะห์และออกแบบไว้ร่วมกัน
• แผนภาพแต่ละชนิดใช้ส าหรับแสดงรายละเอียดของซอฟต์แวร์แตกต่างกัน ท าให้สามารถเข้าใจโครงสร้างและสถาปัตยกรรมในการพัฒนาซอฟต์แวร์ได้
• สัญลักษณ์ที่น ามาใช้เป็นมาตรฐานเดียวกันในการวิเคราะห์และออกแบบเชิงวัตถุ