What are the Pro’s Con’s on defining value types as either Methods or Properties on Interfaces
i.e
Are the only issues with threaded apps or are these pretty much interchangable ?
public interface IFileSearch
{
int FilesNum();
int FilesNum { get; set; }
bool HasFinsihed { get; set; }
}
The reason that you wouldn’t want it defined as a method is if the implementor needs the value as a property, for example to send to a web service.
In addition, of course, if the concept you are defining through the interface needs to be both readable and updateable then a property is usually a better solution than two methods (one for setting and one for getting).
If the data is not to be updated, I often vacillate on whether to provide a method or a readonly property, but assuming no additional parameters are required and the concept being exposed is truly a piece of data as opposed to an action, I usually end up on the side of providing a property for databinding, reflection, and serialization purposes.