Shortcomings of Encapsulation with Functions
This is a great way to write software. However, there are a number of shortcomings in implementing encapsulation and information hiding with functions only. It is these drawbacks that C++ tries to eliminate with the introduction of classes.
One drawback is that access functions do not indicate to the maintainer what the designer knows, that these functions belong together and access the same data structure. In the examples in this chapter, I was putting the server functions together into the same listing for everyone to see. A better solution is to put functions isLeft(), isRight(), and symbolsMatch() into one file (functions accessing symbols), and the functions initStore(), isEmpty(), saveSymbol(), ...
Get Core C++ A Software Engineering Approach 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.