Naming of namespace and classes [closed]
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#
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.
add a comment |
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#
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 NamespaceExampleDevice
, ClassesMain
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 likeHardware.ExampleDevice.ExampleDevice
, if there are several devices, then name likeHardwar.Devices
, and if not then chooseHardware.ExampleDevice
as namespace and it should contain onlyDeviceCommand
andDeviceConnection
classes
– Ashkan Mobayen Khiabani
Nov 16 '18 at 11:58
add a comment |
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#
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#
c#
edited Nov 15 '18 at 16:10
jpaugh
3,86632468
3,86632468
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 NamespaceExampleDevice
, ClassesMain
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 likeHardware.ExampleDevice.ExampleDevice
, if there are several devices, then name likeHardwar.Devices
, and if not then chooseHardware.ExampleDevice
as namespace and it should contain onlyDeviceCommand
andDeviceConnection
classes
– Ashkan Mobayen Khiabani
Nov 16 '18 at 11:58
add a comment |
1
Why don't you do something like NamespaceExampleDevice
, ClassesMain
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 likeHardware.ExampleDevice.ExampleDevice
, if there are several devices, then name likeHardwar.Devices
, and if not then chooseHardware.ExampleDevice
as namespace and it should contain onlyDeviceCommand
andDeviceConnection
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
add a comment |
0
active
oldest
votes
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
1
Why don't you do something like Namespace
ExampleDevice
, ClassesMain
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 likeHardwar.Devices
, and if not then chooseHardware.ExampleDevice
as namespace and it should contain onlyDeviceCommand
andDeviceConnection
classes– Ashkan Mobayen Khiabani
Nov 16 '18 at 11:58