This is the second part of the UML posts. You can find the first part here. As you may have imagined, there are more types of diagrams in UML and I will write about some of them. it has not been easy to learn about it but I’ll do my best. I will discuss about state diagrams, package diagrams, component diagrams and GRASP (an extra topic).
The interesting thing when you are learning UML is that you need to understand some object oriented concepts. I had to remember the following:
Interfaces
It is when you force a class to have certain properties. In Object Oriented Programming, it is a description of all functions that an object must have in order to be certain type of object. In languages like Java you need to specify which interfaces are suitable for an object but in some others like Go you don’t need to do that. The language checks if your structure contains the required methods and properties.
Association types
I see it each semester (more or less) and yet I have not learned it all. The reason is that I don’t usually create UML diagrams and that is something that I need to fix. The next image is great and it speaks by itself.
Diagrams again
State diagram
I like the video from below. Basically a state diagram is a deterministic finite automata. A state machine. If you have taken any course about Theory of Computation you know what I’m saying. You have states, events and transitions between them. They are very useful when you want to show the dynamic aspects of your system. There are a few steps to create one:
- define the states
- describe the states
- draw the transitions
- define the transition triggers
Package diagrams
They are used to simplify the simplicity of the ideas in your model. Basically you specify a hierarchy and separate the classes into groups. If you have seen a real software project you may have noticed the naming convention in the folders and the general structure… well, this is similar to a package diagram. You can include dependency arrows too. The following video explains it better.
Component diagrams
They are useful when you want to reuse pieces of code. Components are a bunch of classes that communicate using interfaces. You have required interfaces and provided interfaces. This is represented using arrows… Honestly I didn’t like this one and maybe I will not use it in soon.
GRASP
Finally, the extra topic: GRASP. This is a cool concept. It means «General Responsibility Assignment Software Principles». This is really useful when you want to write efficient and clean code. It consists of the following 9 principles that must be well defined in your project.
- Creator
- Information expert
- Low coupling
- Controller
- High cohesion
- Indirection
- Polymorphism
- Protected variations
- Pure fabrication
I will not cover all of them but for example the Creator principle is that you ask the question «who instantiates that object?». And by answering all the 9 questions the result may be a good design for your system. You can check more about it in the following link.
References.
https://www.youtube.com/watch?v=-PYYRTlymPU
https://www.youtube.com/watch?v=-PYYRTlymPU
https://study.com/academy/lesson/grasp-design-patterns-in-object-oriented-design.html















![[QueeN]](https://farm4.staticflickr.com/3335/3446011876_2e992dab6e_b.jpg)

