fbpx
Welcome, Guest
Username: Password: Remember me
Share your code snippets, screen shots etc. here
  • Page:
  • 1

TOPIC: Naming Namespaces

Naming Namespaces 2 years 8 months ago #409

  Frank Maraite's Avatar Topic Author Frank Maraite Offline Posts: 173
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

Please Log in or Create an account to join the conversation.

Naming Namespaces 2 years 8 months ago #411

  wriedmann's Avatar wriedmann Offline Posts: 1567
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
Wolfgang Riedmann
Meran, South Tyrol, Italy
This email address is being protected from spambots. You need JavaScript enabled to view it.
www.riedmann.it - docs.xsharp.it

Please Log in or Create an account to join the conversation.

Naming Namespaces 2 years 8 months ago #414

  Otto's Avatar Otto Offline Posts: 141
https://msdn.microsoft.com/en-us/library/ms229026(v=vs.110).aspx we (try to) use the MS standard.
For example: Piramide.IVPA.CommunicationLayer

Please Log in or Create an account to join the conversation.

Naming Namespaces 2 years 8 months ago #415

  Frank Maraite's Avatar Topic Author Frank Maraite Offline Posts: 173
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

Please Log in or Create an account to join the conversation.

Naming Namespaces 2 years 8 months ago #416

  Frank Maraite's Avatar Topic Author Frank Maraite Offline Posts: 173
Otto,

good point!

Please Log in or Create an account to join the conversation.

Naming Namespaces 2 years 8 months ago #417

  Chris's Avatar Chris Offline Posts: 1164
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
XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

  • Page:
  • 1