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();
}
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.
I generally put them on both, however, they do not say the same thing. The interface's comment should describe the abstract purpose of this method/interface. While the concrete comment will talk about the implementation specifics of the method/class in the context of the interface's purpose.
I put them in both, but its a pain keeping them in sync, when in doubt I only put them on the interface.
I do this because I like the tooltip when using the code, which should almost always be using the interface...