Rules

Secret ingredients to quality software

Edit
Info

Do you use one class per file?

Created on 04 Dec 2009 | Last updated by System Account on 20 Oct 2010 08:56 AM (over 10 years ago)

Each class definition should live in its own file.

Reasons:

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. For example:

class MyClass

 
{


        ...


}




class MyClassAEventArgs


{


        ...


}




class MyClassBEventArgs


{


        ...


}




class MyClassAException


{


        ...


}




class MyClassBException


{


        ...


}
      Bad example - 1 project, 1 file.
Adam CoganAdam Cogan
Ryan TeeRyan Tee

We open source. This page is on GitHub