Pierce T. Wetter III
This gets discussed a lot, so there's plenty of examples around. For instance, here's an implementation by someone else I found via Google: http://homepage.mac.com/i_love_my/code.html
...
For "forecasting and recall" on www.marketocracy.com we record every trade already, so it was fairly easy in the business logic to add methods so that you could "time travel" to any point in time. That is, a trade adds shares to your account while subtracting from your cash (or the reverse). So shares on any position at any point in time is sum(trade.shares where date < desired time). So we've been able to avoid the need for an audit trail, because we already have an "accounting model" in that every operation is recorded as a transaction. In fact if I had to do Marketocracy over again, I might implement it as a double-entry bookkeeping system instead.
If I was were going to log every change to every object, some typical hints are that if you subclass EOEditingContext, then prior to any saveChanges() operation you can get a list of the inserted/deleted/changed objects (you have to call processRecentChanges() first). If I was were designing this, I'd make all my EOF objects have a common superclass/interface that implemented something like:
Code Block |
---|
auditTrailChanged()
auditTrailInsert()
auditTrailDelete()
|
...
In psuedo code:
Code Block |
---|
override saveChanges()
self.processRecentChanges()
foreach obj (self.changedObjects)
obj.auditTrailChanged()
foreach obj (self.insertedObjects)
obj.auditTrailChanged()
foreach obj (self.deletedObjects)
obj.auditTrailChanged()
super.saveChanges()
|
Houdah Frameworks:
(scooped from the mailinglist)http://www.mail-archive.com/webobjects-dev@lists.apple.com/msg25686.html
Take a look at Houdah Frameworks. I think the Audit Trail WO:1 WO:2 solution provided by this framework could be helpful.
The Wonder Bug Tracker application also includes support for audit trail. Maybe you can learn something from there.
#1 http://code.google.com/p/houdah-webobjects-frameworks/wiki/HoudahAuditTrail
#2 http://code.google.com/p/houdah-webobjects-frameworks/wiki/AuditTrail
Dov Rosenberg
(scooped from the mailinglist)http://www.mail-archive.com/webobjects-dev@lists.apple.com/msg25683.html
Most of the projects I worked on with this requirement used the built in audit tracking functions of the database. Most DBA's didn't leave the requirement to the developers to enforce. That way everything is tracked in a consistent fashion across applications.
Ken Anderson
(scooped from the mailinglist)http://www.mail-archive.com/webobjects-dev@lists.apple.com/msg25691.html
I use a hybrid approach...
...