The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Factories and ADO.NET in Whidbey

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jon Box

Posts: 244
Nickname: jonbox
Registered: Dec, 2003

Jon Box is a .NET Developer and Regional Director.
Factories and ADO.NET in Whidbey Posted: Feb 8, 2004 12:01 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Jon Box.
Original Post: Factories and ADO.NET in Whidbey
Feed Title: Jon Box's Weblog
Feed URL: http://radio-weblogs.com/0126569/rss.xml
Feed Description: This is a log of my findings and amusements with .NET. I also present information on my presentations and others that I see.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Jon Box
Latest Posts From Jon Box's Weblog

Advertisement

Dan compares Whidbey’s ProviderFactory to the one he developed for our Atomic course.  I’ve included an excerpt below, but the actual post has more details including some code snippets.

The goal of the ProviderFactory that I created was to allow developers to write .NET Data Provider independent code by providing a factory class that created the set of types necessary to work with a particular provider. My implementation followed the principle of the Abstract Factory Pattern documented in the GoF but instead of creating specific factory classes for each provider, relied instead on reflection to create the appropriate types at runtime. As a result my factory was a single class instead of a family of classes related through implementation inheritance. This had the effect of reducing the amount of code I had to write (just over 100 lines of code to support the OleDb, Odbc, and SqlClient providers) but dynamically creating the objects via reflection was slightly slower than providing concrete implementations (I did create a concrete implementation for the Compact Framework book I wrote with Jon Box to work with the SqlServerCe and SqlClient providers on the Compact Framework). My implementation then included the connection, command, parameter, and data adapter and returned interfaces from the factory methods. However, my approach ran into a few problems because the .NET Data Providers were based on interfaces rather than base classes. This manifested particularly when dealing with data adapters since the interface I was returning (IDataAdapter) didn’t include all of the members you would actually need to be able to work with a data adapter and the alternative (IDbDataAdapter) contained the command properties but not other members you would need. As a result, you had to cast from one interface to the other to get your code to work correctly.


Read: Factories and ADO.NET in Whidbey

Topic: Lessons learned from IVBUG Previous Topic   Next Topic Topic: MyDoom (A,B) Worm Removal Tool for Windows XP and Windows 2000

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use