nus-cs2113-AY2021S1 / forum

8 stars 0 forks source link

💡 If you are using PlantUML for class diagrams ... turn off the icons #112

Open okkhoy opened 3 years ago

okkhoy commented 3 years ago

If you are using plant UML, the default styling produces diagrams that use icons for various things like class, interface, public etc., You can turn off the icons feature to give a more standardized UML diagram using the notations we have learned in the class.

See example below:

The code:

@startuml
abstract class MyTaskList{
  - taskList:ArrayList
  - {static} taskCount: int

  +getTaskCount() : int
}

MyTaskList <|-- DeadlineList
DeadlineList : - deadLine: Date
DeadlineList : getDeadline() : Date
DeadlineList : print()

interface Printable
Printable <|.. DeadlineList
Printable : print()

MyTaskList o-- Task
Task --> "<<Enumeration>> \n TimeUnit"
Task : - taskName: String
Task : + getTaskName()

enum "<<Enumeration>> \n TimeUnit" {
  DAYS
  HOURS
  MINUTES
}
@enduml

Produces the diagram below. The icons are annotated for quick reference.

image

You can draw the same diagram using the code below to turn off the icons:

@startuml

hide circle
skinparam classAttributeIconSize 0

class "{abstract} \n MyTaskList"{
  - taskList:ArrayList
  - {static} taskCount: int

  + {static} getTaskCount() : int
}

"{abstract} \n MyTaskList" <|-- DeadlineList
DeadlineList : - deadLine: Date
DeadlineList : getDeadline() : Date
DeadlineList : print()

interface "<<interface>> \n Printable"
"<<interface>> \n Printable" <|.. DeadlineList
"<<interface>> \n Printable" : print()

"{abstract} \n MyTaskList" o-- Task
Task --> "<<Enumeration>> \n TimeUnit"
Task : - taskName: String
Task : + getTaskName()

enum "<<Enumeration>> \n TimeUnit" {
  DAYS
  HOURS
  MINUTES
}
@enduml

You get this diagram: image

okkhoy commented 3 years ago

I realized there are a couple of differences between the 2 diagrams (see getTaskCount() method and Task class); but hopefully you get the idea what I am suggesting.

R-Ramana commented 3 years ago

Would it be an issue if we do not turn off the icon features? Can we leave it as it was?

okkhoy commented 3 years ago

That would be non-standard UML notation. If they are marked as bugs, we will accept them as such. So in your interest, please turn off the icons.