What is the best practice in documenting classes and interfaces. Say if you have a concrete class called Foo, that derives from an interface called IFoo. Where do you put your comments for your methods? Do you duplicate your comments on the Interface as well as the concrete class?
Here is an example where comments are duplicated:
public class Foo : IFoo
{
/// <summary>
/// This function does something
/// </summary>
public void DoSomething()
{
}
}
public interface IFoo
{
/// <summary>
/// This function does something
/// </summary>
void DoSomething();
}
Ideally, only the interface needs to be documented, since it defines the contract that every concrete implementation needs to fulfill.
I would put comments on both.
On interfaces I would comment on the intent behind the interface members and usage.
On implementations I would comment on the reasons for the specific implementation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With