nus-cs2103-AY1819S2 / forum

CS2103/T discussion forum
6 stars 1 forks source link

Class diagram: attribute association multiciplity ambiguity #95

Closed fterh closed 5 years ago

fterh commented 5 years ago

In the textbook (Tools → UML → Class Diagrams → Associations as Attributes), this image is provided as an example of showing association multiciplity using attributes:

https://nus-cs2103-ay1819s2.github.io/cs2103-website/book/uml/classDiagrams/associationsAsAttributes/what/images/board.png

But in an earlier part of the textbook, it's mentioned that the class diagram attribute format is: access_modifier name: type = default_value.

So something like squares: Square[100] - it's ambiguous if this means a Square array of size 100, or an association multiciplity of 100, right? And if it's the latter, shouldn't the type not be "Square", but be something like an array of Square, or an arraylist of Square? So shouldn't I really be writing squares: Square[] [100] or squares: List<Square> [100] instead?

ccristina commented 5 years ago

Hi,

We encourage other students to reply :)

Best regards, Cristina.

daviddl9 commented 5 years ago

From my understanding (please correct me if I'm wrong), since class diagrams are an abstraction to represent the architecture (and not behaviour) of the solution, the exact syntactic details of the implementation does not matter so much. Instead, as long as the diagrams are understandable by developers viewing them, it serves it's intended purpose.

For example, in this case, Square[100] could be an ArrayList<Square> of size 100, array of squares of size 100, or LinkedList<Square> of size 100. The exact details of implementation is not so important here, what's more important is communicating that there are 100 squares associated to the board, to any developer trying to understand the architecture of your program.

fterh commented 5 years ago

Okay, thanks!