August 2010
Intermediate to advanced
908 pages
26h 22m
English
Always apply the ServiceContract attribute on an interface,
not a class:
//Avoid:
[ServiceContract]
class MyService
{
[OperationContract]
public void MyMethod()
{...}
}
//Correct:
[ServiceContract]
interface IMyContract
{
[OperationContract]
void MyMethod();
}
class MyService : IMyContract
{
public void MyMethod()
{...}
}Prefix the service contract name with an I:
[ServiceContract]
interface IMyContract
{...}Avoid property-like operations:
//Avoid:
[ServiceContract]
interface IMyContract
{
[OperationContract]
string GetName();
[OperationContract]
void SetName(string name);
}Avoid contracts with one member.
Strive to have three to five members per service contract.
Do not have more than 20 members per service contract. Twelve is probably the practical limit.