[Mono-dev] [Mono-list] SqlCeServer on mono

Manuel de la Pena etil15 at gmail.com
Wed May 16 11:33:42 EDT 2007


Hi Robert

It is definitely a hack, but is it bad design for a application that  
was written using Microsoft tools??

The provider factory is something that the Mono project has added to  
make ADO .Net more robust (unless I got it completely wrong) but it  
is not present in the Microsoft runtime. My assumption is that some  
code that was made without taking mono into account could have been  
coded this way. Maybe the design didn't want any other data  
connection to be used which would increase the encapsulation of the  
design, I've always considered interfaces dangerous if not used  
correctly...

Please tell me why do you considerer it a bad design to use the  
object rather than the interface??? I'm not talking about the example  
code I gave, which is obviously wrong.

Cheers,

Mandel


On 16 May 2007, at 15:10, Robert Jordan wrote:

> Manuel de la Pena wrote:
>>
>> The problem is that for some reason the people a Microsoft decided to
>> use a completely new namespace for SqlCe server. That is, they have
>> implemented a SqlCeDataReader, SqlCeCommand etc...
>
> All DB providers are implemented using this scheme.
>
>> My question is the following.. If someone has already created an
>> application using the Visual studio tools and have made some code  
>> such as
>>
>> public void Method(){
>>
>>     SqlCeConnection conn = new SqlCeConnection(connectionString);
>>     SdlCeCommand sql = new SqlCeCommand("SELECT * FROM table", conn);
>>
>>     SqlCeDataReader dataReader = sql.ExecuteReader();
>>
>>     while(dataReader.Read())
>>     {
>>         //blah blah blah
>>     }
>>
>> }
>>
>> Should we allow them to compile the code with out changing the  
>> code, or
>> on the other hand should you force them to use the more correct code:
>>
>> public void Method(){
>>
>>     IDbConnection conn = new SqlCeConnection(connectionString);
>>     IDbCommand sql = new SqlCeCommand("SELECT * FROM table", conn);
>>
>>     IDataReader dataReader = sql.ExecuteReader();
>>
>>     while(dataReader.Read())
>>     {
>>         //blah blah blah
>>     }
>>
>> }
>>
>> We all agree that the second code is a more correct one since it  
>> allows
>> to easily change of db technology, but we can also agree that  
>> there are
>> the hell of a lot of programmers that do not use the interfaces  
>> and use
>> the objects instead. What I'm proposing is to create the name  
>> space to
>> avoid making people change their code when compiling on linux, at the
>> end of the day that would make the switch easier for programmers,
>> wouldn't it??
>
> I don't agree. Broken design has to be fixed in code rather than
> with runtime hacks.
>
> The recommended way is to employ a provider factory:
>
> http://www.mono-project.com/Provider_Factory
>
> Robert
>
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list




More information about the Mono-devel-list mailing list