[Mono-devel-list] ADO.NET driver upgrade - class naming and namespace query

Rafael Teixeira monoman at gmail.com
Mon Dec 27 13:30:21 EST 2004


Hi Tim,

> Is there any guidance as to what is best practice here, either for
> ADO.NET
> or for .NET generally?

Generally the ADO.NET provider are just plain flexible. They are the
same always and cope with many versions of the server/backend, at most
some parameter in the connection string says what kind/version of
backend to connect.

So in you case you can rename and "internal"-ize the old classes,
design new internal "version3" classes, and recreate the public
classes as wrappers (UML Aggregation) that implement the GOF Strategy
Pattern to use the appropriate internal classes for the solicited
backend.

Somewhat like:

internal class SqliteConnection2 ...
internal class SqliteCommand2 ...
internal class SqliteDataReader2 ...

internal class SqliteConnection3 ...
internal class SqliteCommand3 ...
internal class SqliteDataReader3 ...

public class SqliteConnection ...
public class SqliteCommand ...
public class SqliteDataReader ...


In truth many things may be reused and so you may have more
hierarchical design, with some functioning superclasses just
specialized for each backend.

Hope it helps,

On Mon, 27 Dec 2004 17:54:30 -0000, Tim Anderson <Tim at onlyconnect.co.uk> wrote:
> I've been working on the Mono Sqlite 2.x client
> (http://www.go-mono.com/sqlite.html) in order to make it work with
> Sqlite
> 3.0. I haven't done much yet with Mono itself, but I find this code
> useful
> for working with Sqlite in Microsoft .NET; I'll also try it with Mono
> itself. I'm wondering what would be the
> best way to name the classes.
> 
> The Sqlite data format changed from version 2.x to 3.x, so I need a
> different set of classes for the new version. Currently the namespace is
> 
> Mono.Data.SqliteClient, and within this there are classes such as:
> 
> SqliteConnection
> SqliteCommand
> SqliteDataReader
> etc
> 
> My first instinct is to add new classes in the same namespace:
> 
> SqliteConnection3
> SqliteCommand3
> SqliteDataReader3
> etc
> 
> This way, you can use the version 2.x and 3.x clients side by side.
> However,
> another approach is to create a new namespace, say
> Mono.Data.SqliteClient3,
> and stick with the old class names. Or to have a new namespace *and* new
> 
> class names.
> 
> Is there any guidance as to what is best practice here, either for
> ADO.NET
> or for .NET generally?
> 
> Tim
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 


-- 
Rafael "Monoman" Teixeira
---------------------------------------
I'm trying to become a "Rosh Gadol" before my own eyes. 
See http://www.joelonsoftware.com/items/2004/12/06.html for enlightment.



More information about the Mono-devel-list mailing list