Manujaya Premathilaka
Manujaya Premathilaka

Reputation: 197

Adding constructors and destructors in a UML class diagram for C++ classes

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

Answers (2)

Gerd Wagner
Gerd Wagner

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

Marco
Marco

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

Related Questions