|
An ordinary VB developer shares his own successes and failures |
|
| Home News Articles Resources Tips Downloads About me | ||
The DataTable wrapper design pattern considered harmfulA real life example of how a poorly thought out up-front design can hurt a project at a later stage.The project in question is about adoption of the Eurovoc thesaurus (see links) in the National Council of Slovak Republic. (Hopefully, I'm not disclosing something confidential; otherwise you won't hear me for some time. )
The goal
of the first part of the project is to
provide the parliament librarians with a tool
to manage the thesaurus and to allow them to
incorporate ongoing changes mandated by the
EU Eurovoc committee.
I took over this part of the project as a project lead, along with my junior programming buddy, Andy.
After analyzing the preliminary requirements
it became clear that the thesaurus management
application wouldn't be anything
revolutionary. Yes, the user interface called
for some sophisticated display and editing
tools. But the rest of the application was
still a little bit boring -
I didn't want the UI controls to directly
manipulate the ADO.NET
I've invented something I proudly called the
"DataTable wrapper design pattern", where a
server-generated
As an example, let's have a
Public Function GetToplevelDescriptors() As DescriptorInfoCollection
Dim DescriptorsTable As DataTable = _
ServerReader.GetToplevelDescriptors(...)
Dim Collection As New DescriptorInfoCollection(DescriptorsTable)
Return Collection
End Function
The DescriptorInfo class and the
corresponding collection class are shown
here:
The key points are:
Efficient? Nope! But I was still so vainglorious that I was effectively blind!
I went out to implement the Everything looked fine until we had to implement a thesaurus search feature, which should look like this:
SearchResultsView
control and it looked fine. But when I've
reviewed the code I've realized that under
the covers, Andy created a private DataTable, copied
the nice TermCollection into it and finally
bound the private DataTable to the DataGrid.
"Why didn't you bind to the TermCollection directly?" I asked. "It doesn't work. The TermCollection doesn't implement the required IList interface." Andy replied. Oops!
I sat down and tried to design the
And the moral of the story? There are several of them, IMHO:
Watch out! © Palo Mraz, Monday, July 21, 2003 Linkshttp://europa.eu.int/celex/eurovoc/ - the official Eurovoc site.http://msdn.microsoft.com/library/en-us/cpguide/html/cpconworkingwithtypeddataset.asp - MS documentation about typed DataSets. http://dotnet.di.unipi.it/EcmaSpec/PartitionV/ - .NET framework naming guidelines (see partition D), and much more. A must read, IMHO. (You already have the spec on your hard drive - it is part of the VS.NET installation. On my machine it is in the D:\Program Files\Microsoft Visual Studio .NET\SDK\v1.1\Tool Developers Guide\docs folder.) http://www.ingorammer.com/RemotingFAQ/ - Ingo Rammer's .NET remoting FAQ. http://www.rds.com/doug/weblogs/webServicesStrategies/2002/11/18.html#a726 - a nice definition of loose coupling. http://www.nrsr.sk/ - The official web page of the Slovak Parliament.
|
||
|
|
||
| ©2003-2007 Palo Mraz. All Rights Reserved. See my 'new browser window' policy | ||