There is certain implementation pattern in C++, that I describe below, it is used in std::iostream library and other similar libraries.
Can anybody recall name of this pattern?
The pattern is described like this:
– There is central class IO used for output of data, or for conversion of data (e.g, std::ostream).
– for every application class for which output conversion is defined, “converters” are GLOBAL functions, not member functions of IO. The motivation for this pattern is
(1) designer of IO wants to have it “finished”, not needing any changes when another application class with convertor is added, and
(2) because you want IO to be a small manageable class, not a class with 100 members and 1000s of lines. This pattern is common when decoupling is needed between IO class and multitude of “user” classes.
What is name of this pattern?
looks like it’s the Herb Sutters’ “Interface Principle”
at least I read it from one of his books
the interface must be minimal, all functions, which do not need private data (for compiling or runtime speed), should be in outer functions.