Microsoft.Data.dll - “Someone on the Internet is wrong!”

I’ve had a few posts on the topic of Microsoft.Data.dll sitting open in my browser for a few days, and I keep coming back to them trying to work out what I think of it. In some ways it doesn’t matter, because I’m never going to use it – which is fine, because I’m not the intended demographic.

If you’ve not seen it already and want to get enraged/interested (pick one!), then basically the syntax is a simplification of ADO.NET and LINQ allowing queries such as the following:

 
  using (var db = Database.OpenFile("Northwind")) {
        foreach (var product in db.Query("select * from products where UnitsInStock < @0", 20)) {

            Response.Write(product.ProductName + " " + product.UnitsInStock);

        }

    }

A lot of the rage against it seems to be that we shouldn’t make it easier for people to shoot themselves in the foot by writing bad code, but is that really the responsibility of the framework? I’m sure you’ll find people doing stupid things with Entity Framework, NHibernate, LightSpeed, LLBLGenPro, not to mention more obvious candidates such as old school ADO.NET, PHP and hundreds of other technologies.

The post Microsoft.Data, because the 90s were so good, we want to do them again made me realise that a lot of people want to think that everyone out there knows about SQL injection, isn’t coding SQL directly in their web applications, and is thinking carefully about their data access strategy simply because it’s 2010 – but that’s just not true. People have and will continue to create bad code no matter what tools are available to them for a variety of reasons, and nothing that anyone can ever do will eliminate that completely as long as humans are walking, sitting and coding.

It leads me to thinking about some of the official ASP.NET examples floating around, a lot of which can simply be misleading to a new developer. Showing someone how to drag, drop and configure a DataSource control and then throw it against a GridView is all good and well, but it’s not the only way to do things – it’d give a better view of the overall picture to have a few different levels of example available so the new reader has a chance to peruse a few examples – even if they pick the simple example to start with, maybe at least they’ll be aware that there are other options out there and make a mental note to go and read more one day.

So many of the ASP.NET examples which Microsoft provides work”, but are hardly used in professional development. How is someone new to the technology stack supposed to know that other than finding out the hard way?

I guess I just don’t see people trying to act all puritan simply because a framework they’re passionate about contains something they don’t like or won’t use as being overly constructive. I can see where the passion comes from (especially given some of those developers will inherit something done wrong one day and scream WHY OH WHY), but I’m really having a hard time getting outraged at providing developers with other options. Without thinking about this too much, I’d probably prefer to come across someone using the code snippet above than some of the other horrible half assed approaches to data access I’ve seen in my time – simply because of the fact that the LINQ query above would be a great candidate for some quick wins via some easy refactoring.

To me it’s the naming of the DLL that’s the worst part – Microsoft.Data really does sound quite official – Microsoft.Data.Lite or something which signifies that it is by no means the end all and be all choice when it comes to data access might have been a much better choice, as well as being a simple way to give new developers a clue that there’s a bigger world out there – the world of ranting in blog comments about the “right” way to do things.

Link: Microsoft.Data.dll - A re-introduction

Link: Introduction to Microsoft.Data.dll

Link: Microsoft.Data: Why It's Not All Bad

Tags: , , ,

Posted on Wednesday, August 11, 2010 8:58 PM |

Like this? Share it!

No comments posted yet.

Post a comment
Please add 7 and 7 and type the answer here:
Remember me?
Ensure the word in this box says 'orange':