This message is inspired by the global:: example Robert showed in his beta 7a announcement.
It adresses the confusion/trouble we get if our namespaces conflict with namespaces introdused by other people. In case of the System namespace it may be a fault by ourself. But where should we place classes, that indeed belong to our own 'System'? The answer is clear:
Put your name/your company name in front of your own namespace!
All my namespaces begin with (obvious) 'FrankMaraite.'. I have, for example
FrankMaraite.CadBase
FrankMaraite.ViewModels
or, to match the example
FrankMaraite.System
or
FrankMaraite.MyApp1.System
Doing this is much clearer to read then using global::System or something like this.
Frank
Naming Namespaces
Naming Namespaces
Hi Frank,
ideally the namespace prefix would be inspired by the inverted internet domain of the company, in my case
it.riedmann
but I have given up this idea - too much to write, and since the name of the library assemblies should reflect this also, I have opted for a shorted form
rdm
so one of my libraries is called rdm.BaseLib.dll, and is using the namespace rdm.BaseLib.
Wolfgang
ideally the namespace prefix would be inspired by the inverted internet domain of the company, in my case
it.riedmann
but I have given up this idea - too much to write, and since the name of the library assemblies should reflect this also, I have opted for a shorted form
rdm
so one of my libraries is called rdm.BaseLib.dll, and is using the namespace rdm.BaseLib.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Naming Namespaces
https://msdn.microsoft.com/en-us/library/ms229026(v=vs.110).aspx we (try to) use the MS standard.
For example: Piramide.IVPA.CommunicationLayer
For example: Piramide.IVPA.CommunicationLayer
-
- Posts: 178
- Joined: Sat Dec 05, 2015 10:44 am
- Location: Germany
Naming Namespaces
Hi Wolfgang,
I put the namespace in the app properties. One assembly, one namespace, nothing to type twice. The same with assembly name.
For the #using statements is the header.cfg useful.
In in case of very few dependencies, only a few #using's. This comes together with decoupling the code.
Frank
I put the namespace in the app properties. One assembly, one namespace, nothing to type twice. The same with assembly name.
For the #using statements is the header.cfg useful.
In in case of very few dependencies, only a few #using's. This comes together with decoupling the code.
Frank
-
- Posts: 178
- Joined: Sat Dec 05, 2015 10:44 am
- Location: Germany
Naming Namespaces
Otto,
good point!
good point!
Naming Namespaces
Hi Frank,
Not saying that you should use this, but just in case you need it sometime, in XIDE, from the menu Application/Advanced you can find a "Add #using directives" option, this allows you to add a certain "using <namespace>" in all prg files automatically. "Remove #using directive" obviously removes the one you specify from all .prg files. There's also a "Add BEGIN NAMESPACE" option, which could be handy in some cases as well.
hth,
Chris
Not saying that you should use this, but just in case you need it sometime, in XIDE, from the menu Application/Advanced you can find a "Add #using directives" option, this allows you to add a certain "using <namespace>" in all prg files automatically. "Remove #using directive" obviously removes the one you specify from all .prg files. There's also a "Add BEGIN NAMESPACE" option, which could be handy in some cases as well.
hth,
Chris
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu