To design interfaces in a way that would be both easy to use and hard to misuse, consider the following exercise. Imagine you are a customer of your interface. You want to implement an e-commerce store that uses your payment gateway, or maybe you want to implement a VR application that connects with the Customer API of the example system we've used throughout this book.
As a general rule regarding interface design, avoid the following traits:
- Too many parameters passed to the function/method
- Ambiguous names of parameters
- Using output parameters
- Parameters depending on other parameters
Why are these traits considered problematic?
- The first one makes it hard to memorize not only the meaning but also the order of the parameters. This can lead to errors in usage, which, in turn, may lead to crashes and security issues.
- The second trait has similar consequences to the first one. By making it less intuitive to use your interface, you...