by Michael J. >> Thu, 20 Jul 2006 23:32:06 GMT
Hi,
This is a query regarding the design of a class to control the transactional layer in a system. I.e. If there was a class representing a customer that needed to be updated, the executing method would typically use a controller method that would in turn use a standardised 'agent' class to perform the update.
The core functionality of this class would be:
- Edition control
- Locking implementation (although the controller level determines locking stategy)
- The actual creation/updating/deletion of the persistent data
- Transaction process flow, i.e. Check edition -> locking -> validation -> transaction
- Storing the relationships between transient data
In the past;
- I have either not used an agent and instead just used a transient copy of a class for any update, which involved having standardised 'transaction' methods on the persistent class. Not really happy with this approach as it weakens the distinction between the database and transaction layer. Also the code is less clear.
- or created a 'agent' class that replicated the persistent class closely. i.e. had all the same attributes etc. Main problem is the onerous nature of maintaining the class structure and the doubling up of the class structure.
My prefered approach would be a hybrid approach that would involve using an instance of an 'agent' class that referenced a transient copy of a persistent for the lifetime of the transaction process. i.e. Changing a customers name might look something like this;
updateAgent := persistentCustomer.fetchAgent;
updateAgent .myTransientCustomer.firstName := 'bob' updateAgent.doTransaction; // edition,validation etc done here
The main issue I have with this is that JADE does not to my knowledge have a 'friendly' language construct like most other OO languages. Which I could use to limit the updating of a persistent objects class properties to another single class. So in effect I have to supply a public interface (set method) to each property. I am not really happy with this as it weakens the seperation between database and transaction layer. i.e what is to stop some jackass from just using the set method from somewhere else in the code? I know all developers should be attempting to use best practice but I really want to force them
Does anyone else have a good strategy for controlling updates in jade or perhaps have a recommendation for improving my methodology?
Or has anyone implemented a 'friend' design pattern in JADE?