6 Don’t surprise your users
This chapter covers
- The Principle of Least Astonishment and how to avoid surprising your users
- Preventing unexpectedly poor runtime performance
- Careful coding with C++ vectors to avoid performance problems
- Applying Programming by Contract to a class and its member functions
We all love surprise parties, but being surprised by the results of a function call is a definite sign of poor design. Well-designed software should not contain any surprises that can cause runtime logic errors or poor performance.
Ideally, when we design a class, its objects will behave and perform just the way its users expect. A user can be another programmer who uses the class or an end user who interacts with the application. Unexpected behavior ...
Get Object-Oriented Software Design in C++ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.