Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
477 views
in Technique[技术] by (71.8m points)

uml - How to indicate a list of types in a Class Diagram

As the problem states, I am trying to indicate 'multiple' of a type in a Class Diagram- for example, my Class is a lecture:

Lecture

topic : String
lecturer : String
timeStart : Time
studentsAttending : **Insert indication of list of students here**
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Create an association between Lecture and Student. On the student end of the association, create an association end called "studentsAttending" having a multiplicity of 0..*. (I recommend you call that association end "attendingStudent" to be consistent with standards such as ISO 11179, BTW.)

You should probably give the other end of the association a name also, like "attendedLecture", with a multiplicity of 0..*.

Here's an example:

Example

These association ends are properties, owned either by the class on the opposite side of the association or owned by the association. Here's some evidence of this from a UML 2 compliant tool:

enter image description here

When the max cardinality is > 1, the property typically gets a type that is some kind of collection in the technology. For an example in Java: List<Student> attendingStudent. (Although in the technology layer, I prefer to pluralize such properties, which would make that List<Student> attendingStudents.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...