PHPBuilder - The Benefits of Using Objects with Databases Page 3



RSS Twitter
Articles Application Architecture

The Benefits of Using Objects with Databases - Page 3

by: Sam Barnum
|
May 9, 2003

More on Accessors

Below are some other examples of how accessors can be used to good effect. Calculated results are possible, instead of simply returning the static data from the array. One other useful function accessors can play is updating cached values. Since all changes must go through the setX() method, that is a perfect place to reset some cached value which is dependent on X.
Our class hierarchy is evolving as well:
  • Internal manipulation of the $_data variable has been replaced by the private methods _getData() and _setData().
  • These generic methods have been moved to an abstract superclass of the User class called Record.
The Record class handles the details of accessing the $_data array, calling validation methods before properties are modified, and posting change notifications to Records, as well as to a central ObjectStore instance.

« Previous Page
1
|
2
|
3
|
4
|
5
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Sam Barnum

Comment:



Comment:

(Maximum characters: 1200). You have characters left.