Reputation: 197
When writing a UML class diagram for C++ code, is it necessary to include constructors and destructors of the relevant class?
Upvotes: 4
Views: 7003
Reputation: 5673
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.
Upvotes: 1
Reputation: 391
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.
Upvotes: 0