When designing public APIs for libraries, avoid trying to guess user intent by inferring behavior from limited information. A code example shows an AddAttachment method that automatically determines content type from file extensions, which limits flexibility and forces library updates for new file types. Instead, let callers explicitly provide the information they already know. This approach prevents blocking users from doing what they need and reduces the need for library changes, especially important for externally shipped libraries where updates are slow to deploy.
5 Comments
Sort: