Communicating Intent in APIs
Recently was trying to work out how to allow custom resources to be specified in Dashen. I already know what data is needed/defined for a resource: a name, a MIME type, and a Stream. We can make this required data known very easily: public class Resource { public string Name { get; private set; } public string MimeType { get; private set; } public Stream Content { get; private set; } public Resource(string name, string mimeType, Stream content) { Name = name; MimeType = mimeType; Content = content; } } As all the parameters can only be set through the constructor, you are communicating that they are all required....