Moweryiana
A Collection of Documents by David L. Mowery
pseudoPODs add properties to C++, which is a way of invisibly calling get() & set() functions. Ordinarily someone who wants to use a member of a class that is POD (Plain Old Data), such as an integer, can simply read or write the POD using statements like:
x = fred.int1; |
or |
fred.int1=37; |
If, however, the class has to execute some code to find out what the current value of the member is, or change it, then anyone who wants to read or write the member must instead use function calls, such as:
x = fred.get_int1(); |
or |
fred.set_int1(37); |
pseudoPODs hide that difference by adding code to the class that implicitly converts what appear to be simple POD reads and writes to the smarter get() & set() calls, thereby simplifying the class' user interface, and reducing the cost of using and maintaining the class.
pseudoPODs:
improve code readability, e.g. ++fred.int1; is easier to figure out than fred.set_int1(fred.get_int1()+1);
improve modularity & abstraction by hiding whether the member is POD or something smarter that executes get() & set() code, which ideally should be an invisible internal implementation detail buried inside the class.
are easy to code - they require 1 additional line to include the .h file, plus 1 additional line per member, and rely on the familiar get() & set() functions, so the coder doesn't have to learn new coding techniques, nor anything new about how C++ works.