views:

431

answers:

2

I'm currently trying to draw a class diagram of a couple of namespaces in C++.

Right now, some variables and methods inside the namespace(free, not part of classes) are part of the namespace API, others are the external part of some classes API (like operator<< and those).

I'm only willing to represent those methods/vars that expose namespace API, but I can't find a way of doing that with standard UML tools, and can't find any relevant info in the Internet.

any hint?

+1  A: 

UML allow you to design an oriented object application. Class diagram, as the name is explicit, represents the classes and links between them in the application.

It's a concept, so there is no interference with languages. The way you are writing functions in namespace, out of any classes, is not oriented object. So you can not represents them in an oriented object concept.

I suggest you to create a class that contains these static functions. Then you will be able to represent them in your diagram.

Patrice Bernassola
Actually, [non-member methods improve object encapsulation](http://www.ddj.com/cpp/184401197), its not a problem of not being object-oriented, it can be a UML limitation, thats why I am asking, in case I missed something.
Arkaitz Jimenez
In his case it's a UML limitation. My suggestion was to allow him to represent the functions in his diagram without modifying his code (but maybe my explanation was ambiguous)
Patrice Bernassola
+1  A: 

UML is for modelling Object Oriented designs, it is not intended to model implementation idioms. Apply the Principle of a Single Responsibility Principle to determine where the function should exist, either in the core class or a handler class.

Martin Spamer