[Mono-list] [Mono-dev] SqlCeServer on mono
Robert Jordan
robertj at gmx.net
Wed May 16 13:56:45 EDT 2007
Hi Manuel,
Manuel de la Pena wrote:
> Hi Robert
>
> It is definitely a hack, but is it bad design for a application that
> was written using Microsoft tools??
Because the application cannot use another DB provider than the
hard coded one.
> 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
Mono's provider factory is just one of many free factories that
exist. And it happens to run unchanged on MS.NET as well.
> 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.
I didn't say that. You can write factories even w/out employing
interfaces, if you don't like them.
Robert
>
> 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
>
> _______________________________________________
> Mono-list maillist - Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
More information about the Mono-list
mailing list