Hello
r12782 introduces a third-level namespace called "Tools", i.e. Inkscape::UI::Tools. There are some problems with this:
1. While this does follow current practice, I don't think the current practice is any good. The only result of having such deeply nested namespace hierarchies is the need to tediously type this all out, since if there actually is a naming conflict they prevent, it's a symptom of bad design / naming.
2. "Tools" is pluralized, while "Dialog" and "Widget" are not. This is inconsistent.
It is sufficient to put all UI code in Inkscape::UI. This would also remove any doubt over whether to use e.g. "Inkscape::UI::Dialog::Print" (which makes the name as used within the namespace ambigous - "Print" what?) or "Inkscape::UI::Dialog::PrintDialog" (which is redundant) - one would simply use "Inkscape::UI::PrintDialog".
In general, 2 levels of namespaces are entirely sufficient. XML tree goes into Inkscape::XML, UI code goes into Inkscape::UI, object (SP) tree goes into Inkscape::SVG (in the future), and so on.
Regards, Krzysztof
Hi,
- "Tools" is pluralized, while "Dialog" and "Widget" are not. This is
inconsistent. Actually, there's two namespaces: Inkscape::UI::Dialog und Inkscape::UI::Dialogs. So it has never been consistent ;) .
In general, 2 levels of namespaces are entirely sufficient. XML tree goes
into Inkscape::XML, UI code goes into Inkscape::UI, object (SP) tree goes into Inkscape::SVG (in the future), and so on. I'd suggest using the same hierarchy in namespaces that is used for the directories. So when something is put in src/ui/widgets, then the code should be in the namespace Inkscape::UI::Widgets. That's how other languages handle this as well and I think that's not a bad idea. You may use a "using" in you cpp files, that's not a problem. And if you need to many of them, think of whether you can split up the file. If the code is cleanly separated into several layers, then there are not too many dependencies.
Regards, Markus
2013/11/8 Markus Engel <p637777@...1081...>:
Hi,
- "Tools" is pluralized, while "Dialog" and "Widget" are not. This is
inconsistent. Actually, there's two namespaces: Inkscape::UI::Dialog und Inkscape::UI::Dialogs. So it has never been consistent ;) .
Inkscape::UI::Dialogs is a very old thing which should be removed.
In general, 2 levels of namespaces are entirely sufficient. XML tree goes
into Inkscape::XML, UI code goes into Inkscape::UI, object (SP) tree goes into Inkscape::SVG (in the future), and so on.
I'd suggest using the same hierarchy in namespaces that is used for the directories. So when something is put in src/ui/widgets, then the code should be in the namespace Inkscape::UI::Widgets. That's how other languages handle this as well and I think that's not a bad idea. You may use a "using" in you cpp files, that's not a problem. And if you need to many of them, think of whether you can split up the file. If the code is cleanly separated into several layers, then there are not too many dependencies.
C++ is not Java.
Regards, Krzysztof
On 13-11-2013 16:38, Krzysztof Kosiński wrote:
2013/11/8 Markus Engel <p637777@...1081...>:
I'd suggest using the same hierarchy in namespaces that is used for the directories. So when something is put in src/ui/widgets, then the code should be in the namespace Inkscape::UI::Widgets. That's how other languages handle this as well and I think that's not a bad idea. You may use a "using" in you cpp files, that's not a problem. And if you need to many of them, think of whether you can split up the file. If the code is cleanly separated into several layers, then there are not too many dependencies.
C++ is not Java.
Great reply, made me laugh :-) +1
-Johan
participants (3)
-
Johan Engelen
-
Krzysztof Kosiński
-
Markus Engel