[Seaside] Prevayler

Josh Flowers joshflowers@mac.com
Sun, 17 Mar 2002 22:28:07 -0500


I'm certainly no expert, but the idea behind Prevayler intrigued me 
enough to look into it so I'll tell you what I've discovered so far...

I think the idea is that in a MVC system your model objects are the ones 
that need to be persisted, and with Prevaylence they have absolutely no 
knowledge of the persistence framework - i.e. no special superclass, no 
special calls in mutator methods etc....  Even the objects that 
essentially do know about the persistence framework, your controllers, 
don't know much, they just know that they use Command objects when they 
need to edit model objects.

Commands may seem like a burden (and to some degree they are), but it 
seems to me that they may end up being easier to deal with than 
transactions.  With WebObjects, I find that transactions get lost - I 
find myself unable to call saveChanges() because I may be in the middle 
of a larger transaction, and I don't want to persist it's data to the 
database.  There are ways around this of course, but every solution 
seems to bring up more problems.  With Prevayler I can execute a single 
small command, and know that any other unrelated changes to the system 
will not be persisted by my command.  Again, I'm only just beginning to 
look into Prevayler (and Seaside for that matter), so it may end up 
being a dead end, but so far it does seem like an improvement over other 
object persistence systems I've used.

And of course it's a very new idea - it may be possible to combine it 
with something like Aspect Oriented Programming to make it a truly 
transparent framework.

josh

> On Sun, 17 Mar 2002, Josh Flowers wrote:
>
>> I've ported a slightly modified version of Prevayler 
>> (www.prevayler.org)
>> to Squeak.  It's an almost completely transparent object persistence
>> framework, that should fit well with Seaside (actually I think it will
>> fit much better than EOF does).
>
> Cool.  Maybe you can help - I've noted Prevlayer, and been perplexed by
> it, a number of times.  Is the idea actually that you encapsulate every
> action you might perform on your business objects in these Command
> classes?  That seems extremely heavyweight to me, and hardly 
> transparent.
> What am I missing?  I'd really like someone to give me an example of 
> using
> Prevlayer in a real-world situation, because it's becoming quite a
> prevalent meme, but I clearly don't quite get it.
>
> I've thought somewhat about whether a similar, but much lighter weight
> approach might work in smalltalk - something like a distributed object
> system, but where every remote method call gets timestamped and logged,
> and where objects continually migrate to the server side.  
> Unfortunately,
> this gets hung up on not being able to handle things like blocks being
> passed in as arguments, which is a pretty severe restriction.
>
> At the least, couldn't Commands be methods on a subclass of Prevlayer 
> rather
> than full classes?  I still don't like funnelling everything through a
> single object but that would feel a little more natural.
>
> Cheers,
> Avi
>
>
"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an 
idea, which an individual may exclusively possess as long as he keeps it 
to himself; but the moment it is divulged, it forces itself into the 
possession of everyone, and the receiver cannot dispossess himself of 
it. Its peculiar character, too, is that no one possesses the less, 
because every other possesses the whole of it. He who receives an idea 
from me, receives instruction himself without lessening mine; as he who 
lights his taper at mine, receives light without darkening me. That 
ideas should freely spread from one to another over the globe, for the 
moral and mutual instruction of man, and improvement of his condition, 
seems to have been peculiarly and benevolently designed by nature, when 
she made them, like fire, expansible over all space, without lessening 
their density at any point, and like the air in which we breathe, move, 
and have our physical being, incapable of confinement or exclusive 
appropriation. Inventions then cannot, in nature, be a subject of 
property." - Thomas Jefferson