Madeline is a great persistence alternative to databases. However, explicit
Command objects can be a pain to write and error-prone.
Is it possible to avoid writing explicit Command objects by using (and
extending) “delegate”? Could the delegator take care of command-object
wrapping, so the callers still makes normal method calls?
Is it possible to avoid writing explicit Command objects by using (and
extending) “delegate”? Could the delegator take care of command-object
wrapping, so the callers still makes normal method calls?
Have a look at madeleine/automatic.rb. It includes an interceptor
module that can be mixed into the service you’re using Madeleine with
and all the methods are automatically turned into commands. Very nifty.
Instiki uses this method. It goes one step further, though, and pulls
all the Madeleine goodies into one MadeleineService class that you can
inheirit from to have automatic snapshots setup automatically and
convenience methods for accessing the service as a singleton and for
clearing the database.
What is the recommended way to deal with changes to schema / object
structure? I recall seeing this discussed a long time ago on Prevalence but
am interested in the Ruby best practice.
Is it possible to avoid writing explicit Command objects by using (and
extending) “delegate”? Could the delegator take care of command-object
wrapping, so the callers still makes normal method calls?
Have a look at madeleine/automatic.rb. It includes an interceptor
module that can be mixed into the service you’re using Madeleine with
and all the methods are automatically turned into commands. Very nifty.
Instiki uses this method. It goes one step further, though, and pulls
all the Madeleine goodies into one MadeleineService class that you can
inheirit from to have automatic snapshots setup automatically and
convenience methods for accessing the service as a singleton and for
clearing the database.
What is the recommended way to deal with changes to schema / object
structure? I recall seeing this discussed a long time ago on Prevalence but
am interested in the Ruby best practice.
Ruby’s marshalling of instance variables is more flexible than in Java,
so new, changed or removed fields should be less trouble in Ruby.
We can unmarshal instances of a class even if we only have an empty
class declaration for it, which should make upgrade-scripts easier to
write.
Other than that, I think it’s the same issues as when doing object
prevalence in Java.
What is the recommended way to deal with changes to schema / object
structure? I recall seeing this discussed a long time ago on Prevalence but
am interested in the Ruby best practice.
Ruby’s marshalling of instance variables is more flexible than in Java,
so new, changed or removed fields should be less trouble in Ruby.
We can unmarshal instances of a class even if we only have an empty
class declaration for it, which should make upgrade-scripts easier to
write.
Other than that, I think it’s the same issues as when doing object
prevalence in Java.