Re: DataContextFactory

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Sep 15 2005 - 18:05:15 EDT

  • Next message: Mike Kienenberger: "Re: DataContextFactory"

    On Sep 15, 2005, at 5:39 PM, Mike Kienenberger wrote:

    > We need to support the most common use case (subclassing DataContext
    > and making some minor change to it) and that requires that we can call
    > the same method that would have been called before. Ie,
    >
    > if (null == dataContextFactory) {
    > context = new DataContext(this, new ObjectStore
    > (snapshotCache));
    > }
    > else {
    > context = dataContextFactory.createDataContext(this, new
    > ObjectStore(snapshotCache));
    > }

    Creating ObjectStore doesn't adds *that much* complexity to a
    potential custom factory, and provides a whole lot of extra
    flexibility. If we are going in this direction already, why stop half-
    way? We can post this as an example on Wiki. One extra line of code:

    public DataContext createDataContext(DataDomain parent) {
        ObjectStore os = new ObjectStore(parent.getSharedSnapshotCache());
        return new MyDataContext(parent, os);
    }

    Ok, when taking shared cache flag into account, it will be a little
    more complex, but still...

    > If you want a custom ObjectStore, maybe we need an
    > ObjectStoreFactory too :)

    Heh, then we need a "builder" object - I guess that's the pattern
    name for the "multi-step factory" :-)

    Andrus



    This archive was generated by hypermail 2.0.0 : Thu Sep 15 2005 - 18:05:18 EDT