C # class naming conventions and class / subclass when the top namespace contains the base class and the inner namespaces contain subclasses

I am trying to create a class library for a specific engineering application, and I am trying to make my class and space name conventions meaningful.

I have the following situation:

namespace Vehicle{

    class Wheel{...} //base class for Wheel objects
    class Engine{...} //base class for Engine objects
    ...
    namespace Truck{ 
        class Wheel: Vehicle.Wheel{...} //Truck specific Wheel object
        class Engine: Vehicle.Engine{...} //Truck specific Engine object
        ...
    }

    namespace Car{ 
        class Wheel: Vehicle.Wheel{...} //Car specific Wheel object
        class Engine: Vehicle.Engine{...} //Car specific Engine object
        ...
    }
    ...
}

The code is used in such a way that all these classes will have to be referenced from the same area. Probably the following situation:

...
Vehicle.Wheel.DoSomething();
Vehicle.Truck.Wheel.DoSomething();
Vehicle.Car.Wheel.DoSomething();
...

In these circumstances, I better give classes more specific names.

namespace Car{
    class CarWheel: Vehicle.Wheel{...} //Car specific Wheel object
    ...
}

, , , ? , alaising , , corret?

:

Vehicle.Car.CarWheel

Vehicle.Truck.TruckEngine

.

, , , .

+5
2

, (, , Vehicle Car), :

namespace Vehicles;
namespace Vehicles.Cars;
namespace Vehicles.Trucks;

, , , , , - :

class CarWheel : Wheel
class TruckWheel : Wheel

"" .NET Framework, , System.Xml Xml System.Data.SqlClient, Sql. , using, , . ?

Vehicles.Cars.Wheel wheel = new Vehicles.Cars.Wheel();

CarWheel wheel = new CarWheel();

, , .


: , , (.Cars, .Trucks ..), , , , , ,

using Vehicles;
using Vehicles.Cars;
using Vehicles.Trucks;
using Vehicles.SomethingElse;
using Vehicles.YetAnotherThing;

, using , . , , , , .

+17

, .

Car, Truck ..? , namespacese. , , ...

+4

All Articles