Week 5
This week I chose to expand my knowledge on UML class diagrams in PlantUML. I referred to the PlantUML website where they go over every command that is available to use and how they work. I wanted to read up on class diagrams to prepare myself for creating them in the homework assignment on UML diagrams and for refreshing my knowledge on UML.
The website goes through all the types of elements you can create, relationships between them, putting labels on relations, defining visibility, adding methods and variables, and how to add notes.
-The UML block is contained in “@startuml” and “@enduml”. In the dev container we used in class it is contained in ““`plantuml" and
““`”.
-To create a class, use “class <name> {<body>}”. If you want to make an abstract class or interface, you would do “abstract <name> {<body>}” or “interface <name> {<body>}”.
-To define visibility modifiers for attributes and properties, use + for public, – for private, # for protected, and ~ for package private. By default, the diagram will show these symbols in colors and shapes, but that can be changed if wanted. A static attribute is defined with
“{static}” before the name.
-The site shows a lot of ways to create notes and all the things you can do to change them, like location, size, color, line breaks, etc, which can be useful to categorize notes in your diagram.
-You can also change the colors of classes and elements, which can help to organize as well.
-Another element you utilize is arrows, when a class is defined, you can say “implements <class>” or “extends <class>” and it will automatically use the correct arrow. But, you can create your own arrows for associations by using “–>”, “-[bold]->”, “-[dashed->”, “-[hidden]->, or “-[plain]->” with the class names on either side. Notes can be attached to arrows as well. For example: Order “many” –> “1” Customer
I referenced the site a lot while doing the UML homework for a refresher. While working on the base assignment, I was cross referencing a lot to make sure I was doing it correctly, but when I got to the advanced assignment, I felt a lot more confident and comfortable with creating UML diagrams in VSCode and only needed to reference it for creating static variables.
UML diagrams are essential for smooth code developing and finding any structural issues before you’re too deep in a project. Having the knowledge and practice to create them will definitely help me outside of this class. Using PlantUML is now something I feel like I can say I can do in real life. In the future, if we make more diagrams in class or if in a job they ask me to make one, I feel comfortable telling them I can make one.
From the blog ALIDA NORDQUIST by alidanordquist and used with permission of the author. All other rights reserved by the author.