14Derived Properties
In certain cases, a property may have the only purpose to provide some information that is computed from other information items. For such a derived property, there is no point to allow the user entering a value for it. Examples of derived properties of a class Person are the attributes age and initials. The value of age is computed on demand from the value of the attribute dateOfBirth and the current year. The value of initials is computed from the values of the attributes firstName and lastName.
Unlike in the case of standard properties, the value of a derived property cannot be set by the user. Rather, it is computed from the values of other properties. Consequently, it does not have a setter, but only a getter method. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access