I use the Code Contracts classes in the namespace System.Diagnostics.Contractsto define some contracts for my objects, and I wonder how others call their contract classes when the contract is defined with respect to the base interface. Let me illustrate with a small example:
[ContractClass(typeof(AnimalContract))]
public interface IAnimal
{
}
[ContractClassFor(typeof(IAnimal))]
public class AnimalContract : IAnimal
{
}
In this example, I named the contract class AnimalContract, but is there a better name? Since the contract is defined by interface, I almost want to name the class IAnimalContract to illustrate its contract for the IAnimal interface. Thus, when I see two elements in the solution explorer, they visually “connect”, which helps to keep things clean and clean in my head. Of course, the contract itself is not an interface, so calling it that way just smells bad to me.
What do you guys (and girls) call your contract classes in these cases? Is there a generally accepted agreement?
source
share