When writing a UML class diagram for C++ code, is it necessary to include constructors and destructors of the relevant class?
2 Answers
In many cases, adding constructors/destructors to a C++ class diagram would just be textual boilerplate noise and not really meaningful. Only if you want your diagram to be a complete documentation of your C++ classes, you may want to add constructors.
Contrary to what @Marco is saying below, this is not a matter of the underlying business logic, but a purely ergonomic issue of avoiding cluttering and noise in (typically complex) diagrams.
1 Comment
The constructor can be added if it's part of the business logic, you just don't add a return type.
Would be under the functions/methods section:
+ClassName()
I would not add destructors. Again, depends on whether your business logic needs it.
3 Comments
__init__(self, parms) or in some meta language init(parms) -> ClassName or whatever is convenient.