Consistency in an API allows users to make use of what they have learned about how one part of the API works when they start working with another, similar part of the API. One way to measure and describe how consistent your API is, is as follows :
For two or more similar user goals that the API supports, describe how similar the code required to accomplish these goals is.
In the System.IO namespace, two similar goals might be:
The code required for these two goals is as follows
//Append the existing contents of the file
StreamWriter sw = new StreamWriter("C:\\test.txt", true);
sw.WriteLine("Text to append to test.txt");
//Overwrite the existing contents of the file
StreamWriter sw = new StreamWriter("C:\\test.txt", false);
sw.WriteLine("Text to overwrite in test.txt");
In both cases the code is very similar. The only difference is the value of the second parameter in the StreamWriter constructor.
Consistency can be defined in the following terms
In general, most users like to work with an API that is fully consistent.