Closed cheahTJ closed 6 months ago
hi, im not too sure about 1 and 3 but for point 2, i believe if the method returns void, there is no need to indicate the return type.
For point 4, I believe when we compare class vs object diagrams, we exclude the methods and the multiplicities from the object diagrams. I think this section from the textbook could be helpful in distinguishing the two. https://nus-cs2103-ay2324s2.github.io/website/se-book-adapted/chapters/uml.html#object-vs-class-diagrams
Hope it helps!!
- Understand that parameters of method can be included:
add(X)
, but is it WRONG to not have it?
We encourage the unofficial notation (...)
to indicate parameters have been omitted. Otherwise there is no way to differentiate between a method that doesn't have parameters and a method that omits parameters.
- It is ok to show the return type of methods:
getItemCount():int
, however if the method is void, will it be represented as suchcount():void
Yes
- ON the same note as 2, if shown in the exams that some methods show the return type, but some methods never show in teh same diagram:
add():int, minus():int, multiply()
, will this be considered as wrong? (if let say we have to decide if such class/object diagrams with such methods show are correct or not)
There will be no such questions In general, you can omit details not relevant to the purpose of the diagram.
- Are there any tricks to know what to EXCLUDE from an object diagram from a class diagram? The tutorial example seems a little hard to grasp, so i was just wondering if there are any tips on this
For this, see @jannaleong's answer
Got it thank you ! @damithc @jannaleong
Sorry but what I dont get for question 4 is that from a class diagrams (like the one in tutorial), when we are needed to draw an object diagram, do we redraw the object diagram from scratch or shall we follow what was drawn in the class diagram already but we modify some things (like in the tutorial question, we omit the drawing of Item object beacuse the StockItem is already an Item, and Inventory object can jsut point directly to StockItem instead). So yeah i was just wondering if there are tricks to drawing object diagrams from a question in general
Hi, I have a these following few questions to clarify:
add(X)
, but is it WRONG to not have it?getItemCount():int
, however if the method is void, will it be represented as suchcount():void
add():int, minus():int, multiply()
, will this be considered as wrong? (if let say we have to decide if such class/object diagrams with such methods show are correct or not)