3 ms·
> straightforward fields which are public and documented The rational (whether right or wrong) in OO for private fields and public "manipulator" methods is tha
by chii 6y ago
> straightforward fields which are public and documented
The rational (whether right or wrong) in OO for private fields and public "manipulator" methods is that the field's representation can be wider than the intended public use. For example, you may store the credit-card number as a string of digits, but only allow the correctly CRC'ed number to be set.
Of course, in a more functional paradigm, you would have a credit card number type (which is just a function that strictly enforces the domain and range of the possible valid values), rather than an object which can have independent identity storing the same information.