Before writing the actual code it is always handy to plan, and design what we want to build. There are so many ways to do so; UML (Unified Modelling Language) is one of them, and there are many types of UML diagrams, such as, Class Diagram, Use case Diagram, Component Diagram, Sequence Diagram.
In my personal opinion, writing codes without at least a class diagram seems very naive. Let’s see how class diagram can help us building a software rapidly.
Let’s assume we are given a task of reading an XML file, renaming the tags based on some given values, and generate a new XML file with the new tags. How would you map this problem!? If we just go for the coding right away, there is a higher chance of fragility somewhere during the development. So it is undoubtedly a better approach to draw a class diagram before writing the code. It doesn’t have to be precise, rather make it simple, and implementable.
As we can see from the diagram above that, we need three different classes to get the job done. And also the implementation becomes easier, reduces our future thoughts when we design a UML diagram of a solution.