Naming of namespace and classes [closed]










4















In C# there are some problems with naming a namespace the same as a class that is included in that namespace.



In my project, I often have the same situation. I have a class that represents an abstraction of an external device (a USB relay for example). The code for such a device looks like this:



namespace Hardware.ExampleDeviceNamespace 

class ExampleDevice

void executeCommand( DeviceCommand command ) ...
void checkConnection( DeviceConnection connection ) ...


class DeviceCommand

...


class DeviceConnection

...




Now I am struggling with a proper name for the namespace ExampleDeviceNamespace and the class ExampleDevice, because I think adding the word "namespace" at the and of the actual name is not very nice. I am using a namespace for the ExampleDevice because I implemented a lot of helping classes like DeviceCommand and DeviceConnection and the namespace Hardware would get very messy without the folders. Do you have any suggestions to solve this problem? I am aware that of the fact, that there is no "right" solution for this question. But I would like to hear some ideas from other programmers.



If you have further questions to my problem, do not hesitate to ask. Thanks in advance for any answer.










share|improve this question















closed as primarily opinion-based by HimBromBeere, Wai Ha Lee, Igor, Progman, itsme86 Nov 15 '18 at 16:16


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.













  • 1





    Why don't you do something like Namespace ExampleDevice, Classes Main Command Connection. Thus you have a standard structure for all your hardware.

    – ikerbera
    Nov 15 '18 at 15:52







  • 1





    How should anyone here give a right or whrong answer on such an opiniob-based question?

    – HimBromBeere
    Nov 15 '18 at 15:54







  • 2





    You need a grouping word. Like Hardware.Example or Hardware.Devices. Do strongly strive to make the connection and command device-independent.

    – Hans Passant
    Nov 15 '18 at 16:05











  • If your namespace and the class inside should have the same names, then obviously something is wrong, because even if you can have the same name then it would be like Hardware.ExampleDevice.ExampleDevice, if there are several devices, then name like Hardwar.Devices, and if not then choose Hardware.ExampleDevice as namespace and it should contain only DeviceCommand and DeviceConnection classes

    – Ashkan Mobayen Khiabani
    Nov 16 '18 at 11:58















4















In C# there are some problems with naming a namespace the same as a class that is included in that namespace.



In my project, I often have the same situation. I have a class that represents an abstraction of an external device (a USB relay for example). The code for such a device looks like this:



namespace Hardware.ExampleDeviceNamespace 

class ExampleDevice

void executeCommand( DeviceCommand command ) ...
void checkConnection( DeviceConnection connection ) ...


class DeviceCommand

...


class DeviceConnection

...




Now I am struggling with a proper name for the namespace ExampleDeviceNamespace and the class ExampleDevice, because I think adding the word "namespace" at the and of the actual name is not very nice. I am using a namespace for the ExampleDevice because I implemented a lot of helping classes like DeviceCommand and DeviceConnection and the namespace Hardware would get very messy without the folders. Do you have any suggestions to solve this problem? I am aware that of the fact, that there is no "right" solution for this question. But I would like to hear some ideas from other programmers.



If you have further questions to my problem, do not hesitate to ask. Thanks in advance for any answer.










share|improve this question















closed as primarily opinion-based by HimBromBeere, Wai Ha Lee, Igor, Progman, itsme86 Nov 15 '18 at 16:16


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.













  • 1





    Why don't you do something like Namespace ExampleDevice, Classes Main Command Connection. Thus you have a standard structure for all your hardware.

    – ikerbera
    Nov 15 '18 at 15:52







  • 1





    How should anyone here give a right or whrong answer on such an opiniob-based question?

    – HimBromBeere
    Nov 15 '18 at 15:54







  • 2





    You need a grouping word. Like Hardware.Example or Hardware.Devices. Do strongly strive to make the connection and command device-independent.

    – Hans Passant
    Nov 15 '18 at 16:05











  • If your namespace and the class inside should have the same names, then obviously something is wrong, because even if you can have the same name then it would be like Hardware.ExampleDevice.ExampleDevice, if there are several devices, then name like Hardwar.Devices, and if not then choose Hardware.ExampleDevice as namespace and it should contain only DeviceCommand and DeviceConnection classes

    – Ashkan Mobayen Khiabani
    Nov 16 '18 at 11:58













4












4








4


2






In C# there are some problems with naming a namespace the same as a class that is included in that namespace.



In my project, I often have the same situation. I have a class that represents an abstraction of an external device (a USB relay for example). The code for such a device looks like this:



namespace Hardware.ExampleDeviceNamespace 

class ExampleDevice

void executeCommand( DeviceCommand command ) ...
void checkConnection( DeviceConnection connection ) ...


class DeviceCommand

...


class DeviceConnection

...




Now I am struggling with a proper name for the namespace ExampleDeviceNamespace and the class ExampleDevice, because I think adding the word "namespace" at the and of the actual name is not very nice. I am using a namespace for the ExampleDevice because I implemented a lot of helping classes like DeviceCommand and DeviceConnection and the namespace Hardware would get very messy without the folders. Do you have any suggestions to solve this problem? I am aware that of the fact, that there is no "right" solution for this question. But I would like to hear some ideas from other programmers.



If you have further questions to my problem, do not hesitate to ask. Thanks in advance for any answer.










share|improve this question
















In C# there are some problems with naming a namespace the same as a class that is included in that namespace.



In my project, I often have the same situation. I have a class that represents an abstraction of an external device (a USB relay for example). The code for such a device looks like this:



namespace Hardware.ExampleDeviceNamespace 

class ExampleDevice

void executeCommand( DeviceCommand command ) ...
void checkConnection( DeviceConnection connection ) ...


class DeviceCommand

...


class DeviceConnection

...




Now I am struggling with a proper name for the namespace ExampleDeviceNamespace and the class ExampleDevice, because I think adding the word "namespace" at the and of the actual name is not very nice. I am using a namespace for the ExampleDevice because I implemented a lot of helping classes like DeviceCommand and DeviceConnection and the namespace Hardware would get very messy without the folders. Do you have any suggestions to solve this problem? I am aware that of the fact, that there is no "right" solution for this question. But I would like to hear some ideas from other programmers.



If you have further questions to my problem, do not hesitate to ask. Thanks in advance for any answer.







c#






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 16:10









jpaugh

3,89132468




3,89132468










asked Nov 15 '18 at 15:49









BlackbriarBlackbriar

805




805




closed as primarily opinion-based by HimBromBeere, Wai Ha Lee, Igor, Progman, itsme86 Nov 15 '18 at 16:16


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.









closed as primarily opinion-based by HimBromBeere, Wai Ha Lee, Igor, Progman, itsme86 Nov 15 '18 at 16:16


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.









  • 1





    Why don't you do something like Namespace ExampleDevice, Classes Main Command Connection. Thus you have a standard structure for all your hardware.

    – ikerbera
    Nov 15 '18 at 15:52







  • 1





    How should anyone here give a right or whrong answer on such an opiniob-based question?

    – HimBromBeere
    Nov 15 '18 at 15:54







  • 2





    You need a grouping word. Like Hardware.Example or Hardware.Devices. Do strongly strive to make the connection and command device-independent.

    – Hans Passant
    Nov 15 '18 at 16:05











  • If your namespace and the class inside should have the same names, then obviously something is wrong, because even if you can have the same name then it would be like Hardware.ExampleDevice.ExampleDevice, if there are several devices, then name like Hardwar.Devices, and if not then choose Hardware.ExampleDevice as namespace and it should contain only DeviceCommand and DeviceConnection classes

    – Ashkan Mobayen Khiabani
    Nov 16 '18 at 11:58












  • 1





    Why don't you do something like Namespace ExampleDevice, Classes Main Command Connection. Thus you have a standard structure for all your hardware.

    – ikerbera
    Nov 15 '18 at 15:52







  • 1





    How should anyone here give a right or whrong answer on such an opiniob-based question?

    – HimBromBeere
    Nov 15 '18 at 15:54







  • 2





    You need a grouping word. Like Hardware.Example or Hardware.Devices. Do strongly strive to make the connection and command device-independent.

    – Hans Passant
    Nov 15 '18 at 16:05











  • If your namespace and the class inside should have the same names, then obviously something is wrong, because even if you can have the same name then it would be like Hardware.ExampleDevice.ExampleDevice, if there are several devices, then name like Hardwar.Devices, and if not then choose Hardware.ExampleDevice as namespace and it should contain only DeviceCommand and DeviceConnection classes

    – Ashkan Mobayen Khiabani
    Nov 16 '18 at 11:58







1




1





Why don't you do something like Namespace ExampleDevice, Classes Main Command Connection. Thus you have a standard structure for all your hardware.

– ikerbera
Nov 15 '18 at 15:52






Why don't you do something like Namespace ExampleDevice, Classes Main Command Connection. Thus you have a standard structure for all your hardware.

– ikerbera
Nov 15 '18 at 15:52





1




1





How should anyone here give a right or whrong answer on such an opiniob-based question?

– HimBromBeere
Nov 15 '18 at 15:54






How should anyone here give a right or whrong answer on such an opiniob-based question?

– HimBromBeere
Nov 15 '18 at 15:54





2




2





You need a grouping word. Like Hardware.Example or Hardware.Devices. Do strongly strive to make the connection and command device-independent.

– Hans Passant
Nov 15 '18 at 16:05





You need a grouping word. Like Hardware.Example or Hardware.Devices. Do strongly strive to make the connection and command device-independent.

– Hans Passant
Nov 15 '18 at 16:05













If your namespace and the class inside should have the same names, then obviously something is wrong, because even if you can have the same name then it would be like Hardware.ExampleDevice.ExampleDevice, if there are several devices, then name like Hardwar.Devices, and if not then choose Hardware.ExampleDevice as namespace and it should contain only DeviceCommand and DeviceConnection classes

– Ashkan Mobayen Khiabani
Nov 16 '18 at 11:58





If your namespace and the class inside should have the same names, then obviously something is wrong, because even if you can have the same name then it would be like Hardware.ExampleDevice.ExampleDevice, if there are several devices, then name like Hardwar.Devices, and if not then choose Hardware.ExampleDevice as namespace and it should contain only DeviceCommand and DeviceConnection classes

– Ashkan Mobayen Khiabani
Nov 16 '18 at 11:58












0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3

Museum of Modern and Contemporary Art of Trento and Rovereto