Do you use one class per file?

Last updated by Brady Stroud [SSW] about 2 months ago.See history

Each class definition should live in its own file. This ensures it's easy to locate class definitions outside the Visual Studio IDE (e.g. SourceSafe, Windows Explorer)

The only exception should be classes that collectively forms one atomic unit of reuse should live in one file.

class MyClass
{
    // ...
}

class MyClassAEventArgs
{
    // ...
}

class MyClassBEventArgs
{
    // ...
}

class MyClassAException
{
    // ...
}

class MyClassBException
{
    // ...
}

Bad example - 1 project, 1 file

Adam Cogan
Ryan Tee
We open source. Powered by GitHub