Distinguishing attributes from properties
In the applications I generate, object properties often have a 1:1 correspondence to columns (that is not quite true as I generate my DAOs to support aliases and aggregates, but that will be a topic for a whole other post!). Lets take a very simple case where we have a user object that maps exactly to a user table, and let's pretend for now we don't need any related objects (addresses or subordinates), aggregate data (comma delimited list of roles, total salary for the user this year, number of vacation days taken, etc.), or aliases (lets pretend the column names in the db are fine for use within the application so we don't need to alias USR_TBL_FLD17_STR35 or something equally horrific to FirstName - it's already called FirstName in the DB) . . .
So, when we load up our iterating user object, the recordset will have a set of column names like FirstName, LastName and DateofBirth. I call those the object properties, and they are distinguished by the fact that in most simple use cases, properties are settable (it is possible to persist changes to them).
However, for a given use case, I may want to expose getters for FullName, FirstName, LastName and Age (but lets say, NOT date of birth). I call those the attributes of the object and they are typically gettable, but not necessarily settable - try asking a user to enter their age and then saving that in a useful manner that would give you their correct date of birth!!!
By making this distinction and requiring metadata for both object properties and object attributes it allows me to generate much richer applications with much more business functionality without having to break out a code editor and actually work for a living! Please keep this concept in mind as we're going to be building on it in future posts.





There are no comments for this entry.
[Add Comment]