So the question is simple. I just do not find the answer on the internet. I think private methods are useless in diagram, not telling much. But maybe I think wrong.
In general UML provides a mechanism to show operation (and attribute alike) visibility. As private feature can be depicted on a diagram it is clear that you can present it on a diagram. However if you show it or not depends what you're modelling. If you're modelling the internal behaviour of the class then yes.
Private methods are an implementation detail of the class, not its public API. If you are using the diagram to show the external interface of the class, or some subsystem that the class is part of, then there is no reason to include them.
Class diagrams are one of the most useful types of diagrams in UML as they clearly map out the structure of a particular system by modeling its classes, attributes, operations, and relationships between objects.
To show a composition relationship in a UML diagram, use a directional line connecting the two classes, with a filled diamond shape adjacent to the container class and the directional arrow to the contained class.
Private methods are an implementation detail of the class, not its public API.
No:
If you are using the diagram to show the external interface of the class, or some subsystem that the class is part of, then there is no reason to include them. They will just add visual noise and confuse the reader.
Yes/Maybe:
On the other hand, if you are trying to communicate the internal design of the class itself, or its tightly coupled collaboration with another class (think of friend
in C++), then it might be appropriate.
Opinion:
UML is not* a 4GL programming language. You use it to convey an idea, design, architecture. You only add information that serves that purpose. It does not have the concept of being "complete". Like text in a book, you only use words necessary for the purpose of conveying the message.
If it is used as part of system documentation, and it needs to show all members, then we just generate it afterwards.
UML is not the goal, it is just a modelling language to communicate with people.
So if it serves the purpose you add it, otherwise you leave it out.
*) some attempts have been made at that, but have not been very succesful (togetherJ springs to mind)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With