Abstracting the "data transport"

Posts   
 
    
Dhominator avatar
Dhominator
User
Posts: 16
Joined: 28-Dec-2004
# Posted on: 28-Dec-2004 23:16:14   

Hey All,

I'm a n00b that just started looking at the product today. Multiple DBMSes is a fact of life for me. Also looking to cache some lookups on fat clients. So...

Is the Adapter approach [basically] a given for multiple DBMSes? Mainly lose lazy load for relations? (same schema all DBMSes)

Any patterns/hacks for supporting lazy load w/Adapter approach (maybe entity-based events)?

If I want to cache a few readonly entities (typed lists) on the client how does this fit into the architecture/approach? #1 Assume simplest thing that could possible work... serialized typed lists as local cache. #2 some other format.

Thoughts? Pointers? confused

Best, /jhd

Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 29-Dec-2004 04:39:19   

Dhominator wrote:

Is the Adapter approach [basically] a given for multiple DBMSes?

IMO Yes

Dhominator wrote:

Mainly lose lazy load for relations? (same schema all DBMSes)

But you gain so much more control with respect to how your application services clients that the tradeoff is well worth it, i.e. you can now snap in remoting, web services, or COM+ to provide the implementation of your DAL. This is much more powerful (for me anyway.)

Dhominator wrote:

Any patterns/hacks for supporting lazy load w/Adapter approach (maybe entity-based events)?

I beleive that what a lot of people do is use controller classes. There are controller template parsers available that build all of the common fetch, save, and delete methods for all entities in an llblgen project. So ultimately you end up with code like this:


string customerId = "1234";
CustomerEntity customer = CustomerController.Fetch(customerId);
customer.FirstName = "Bob";
if CustomerController.SaveEntity(customer)
{
MessageBox.Show("Customer Updated");
}

I am in the process of taking controller classes to the next level to enable COM+ in the controllers.

Dhominator wrote:

If I want to cache a few readonly entities (typed lists) on the client how does this fit into the architecture/approach? #1 Assume simplest thing that could possible work... serialized typed lists as local cache. #2 some other format.

Xin Chen has a book titled developing application frameworks in .NET that demonstrates a straightforward and simple caching service that would fit the bill perfectly. You could even plug in your own storage mechanism if you like. (i.e. use IIS caching instead of the default hashtable approach). The caching framework also uses XML and XPath assist developers in locating cached items.

Here is an exerpt from his book, slightly modified for demonstration with LLBLGen:


        static void Main(string[] args)
        {
            //get the cache object 
            Cache cache = SAF.Cache.Cache.GetSAFCacheService();

            ControllerBase tmpController = ControllerFactory.GetController("UserEntityController");
            UserEntity tmpUser;
            TypedList tmpCustomerOrders;

            //add some objects into the cache service
            tmpUser = tmpController.FetchEntity(1);
            cache.AddObject("/WebApplication/UserEntity/1", tmpUser);

            tmpUser = tmpController.FetchEntity(2);
            cache.AddObject("/WebApplication/UserEntity/2", tmpUser);

            tmpUser = tmpController.FetchEntity(3);
            cache.AddObject("/WebApplication/UserEntity/3", tmpUser);

            tmpController = ControllerFactory.GetController("CustomerOrdersTypedListCustomController");
            tmpCustomerOrders = ((CustomerOrdersTypedListCustomController)tmpController).OrdersByCustId("ABC123");
            cache.AddObject("/WebApplication/TypedList/CustomerOrders/ABC123", tmpCustomerOrders);

            //retrieve the objects as a group
            object[] objects = cache.RetrieveObjectList("/WebApplication/UsersEntity");
            foreach (object o in objects)
            {
                Console.WriteLine("User in cache: {0}", ((UserEntity)o).FirstName);
            }

            //retrieve the object as individual
            string time =(string) cache.RetrieveObject("/WebApplication/GlobalData");
            string name = (string) cache.RetrieveObject("/WebApplication/Users/Xin");

            //remove the object
            cache.RemoveObject("/WebApplication/TypedList/CustomerOrders/ABC123");

            //remove all the object under /Users
            cache.RemoveObject("/WebApplication/UsersEntity");
        }

The code

 Cache cache = SAF.Cache.Cache.GetSAFCacheService();

creates a thread safe singleton object.

Dhominator avatar
Dhominator
User
Posts: 16
Joined: 28-Dec-2004
# Posted on: 29-Dec-2004 16:41:53   

thx info and references.

caching... intend to persist some of the bigger lookup tables on fat client as well as memory cache (singleton). so this sounds doable as well. will work with adatper approach to get a feel for this stuff.

tiers/remoting/alternate datasources... for bigger customers we'll deploy in a 3 tier model... the rest as client-server. remoting is the default implementation plan. additionally mid-term plans include a couple entities via web service. again the Adapter model seems the right choice.

ok, roughed out some entities in the db... time to actually touch the product wink

Best, /jhd

Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 29-Dec-2004 18:22:34   

Dhominator wrote:

ok, roughed out some entities in the db... time to actually touch the product wink

Have fun