DoItYourselfTransactions

This is a rough rendering of a page from the old Prevayler wiki. Please see the new wiki for current documentation.

A transaction scheme that lets clients build their own atomic sets of operations. In an RDBMS, a client can use begin-commit semantics to build its own transactions.

A way to do it in Prevayler would be to have a TransactionCommand, for example, to which a client would be able to addCommand(). When that TransactionCommand executes, it would execute all commands it contains.



I don't think this is a good thing to include with Prevayler simply because it encourages bad software design.

This is a very subtle encapsulation issue: with begin-commit semantics or with an addCommand() function, you are allowing/encouraging client code to define new transactions, new atomic collections of operations WHICH WERE NOT NECESSARILY INTENDED TO BE ATOMICALLY COMBINED.

i.e. You are allowing client code to bring business logic into its own hands in a very subtle way, but that will still bring you trouble.

KlausWuestefeld


I was thinking of maintaining a page on the PrevaylerWiki with an implementation, just to show that this is not a difficult thing to do, but I would leave a warning: "USE AT YOUR OWN PERIL" (and the explanation above). -- KlausWuestefeld

The only case I see an addCommand() method being useful is on the creation of batches of commands. Suppose we already have a Command that changes a given field of a BusinessObject, and the application must apply the same command, with subtle changes in its parameters, to the system. The designer may choose to implement batching in order to achieve some extra performance (by using the same instance of the command and changing its values, caching or using other optimization techniques) while still reusing the original Command's code. What do you think?

CarlosVillela