Microsoft.Data, because the 90s were so good, we want to do them again
I just saw this post, and I had to double check the date of the post twice to be sure that I am reading about something that is going to come out soon, rather than something that have come out in 2002.
This is the code that is being proudly presented as an achievement:
using (var db = Database.Open("Northwind")) { foreach (var product in db.Query("select * from products where UnitsInStock < 20")) { Response.Write(product.ProductName + " " + product.UnitsInStock); } }
Allow me to give you the exact statements used:
The user doesn’t have to learn about connection strings or how to create a command with a connection and then use a reader to get the results. Also, the above code is tied to Sql Server since we’re using specific implementations of the connection, command, and reader(SqlConnection, SqlCommand, SqlDataReader).
Compare this with code below it. We’ve reduced the amount of lines required to connect to the database, and the syntax for accessing columns is also a lot nicer, that’s because we’re taking advantage of C#’s new dynamic feature.
I really don’t know where to start. Yes, compared to raw ADO.Net I guess that this is improvement. But being beaten only thrice a week instead of daily is also an improvement.
I mean, seriously, are you freaking kidding me? Are you telling me that you are aiming to make the life of people writing code like this easier?
We have direct use of Response.Write – because it is so hard to create maintainable code, we decided to just give up from the get go. Beyond that, putting SQL directly in the code like that, including the parameters, is an open invitation for SQL injection.
Next, let us talk seriously, okay. Anyone who had to write ADO.Net code already wrapped it up. Anyone who didn’t isn’t going to.
But given all the times that we have heard “no resources to fix XYZ” from Microsoft, are you telling me that creating a framework that is intended for really bad programmers to slide down the maintainability scale more easily? Is that a valuable use of resources?
Writing code like that is actively harmful, period. There is really no need to deal with those low level stuff in this day and age.
Comments
While I agree that no actual application should be using code like this, the one place it could have value is in scripting. Obviously C# still isn't easily scriptable, but I could see myself calling this new API from a simple IronRuby .rb file to do simple database manipulation - assuming it is something I either couldn't do in pure SQL or didn't want to for some reason. (And yes, I realize that this is not the use case it is being advertised for.)
Completely agree. Worse is the attitude that they're showing (Twitter etc.) "the users don't want to care, or know any better". That's the attitude of a drug pusher, not a responsible company of professionals. A position of authority deserves more care. There will be people copy pasting that code.
That isn't the code. You didn't show the "Compare this with code below it." That's the new code. What you pasted in isn't ASP.NET Web Pages code.
I fully agree here, I saw this post earlier and was quite shocked to see the publication date.
Besides the SQL injection, there's no sign of transaction boundaries, no caching whatsoever and worst of all to write pure SQL in code like that is just plain crazy.
It feels like a lot of the new Microsoft framework ideas (not all, there's some good stuff too), great for demos, but useless anywhere else.
yet another fine example of Microsoft promoting Fisher Price Development
it is indeed truly sad that they are actually spending resources on useless crap like this
ASP.NET team and data access dont go well together. Remember SqlDataSource. It was created by an intern. I am sure that is the case.. in this case too.
Erik,
This is the code that I am riling _against_.
The code in the post shows Response.Write, so you'll have to excuse me assuming that this is how you intended it to be used.
Ayende, I'm saying that code is used to show what functionality would happen by calling our code. As in, you're pointing out bad code that isn't meant for anything other than to show what functionality it covers.
Erik,
The problem is that the code shown is showing so many bad practices that it is scary.
It actively encourages those worst practices.
It's a blog post. Up to the blogger to show it however they want. Nothing will stop someone from building that anyway.
Personally I'd code it like this, but that takes up more space. :P
@{
}
@foreach (var row in query) {
}
But two things with that...there's no markup so it's not real and also you won't be happy with it either. :) Oh and did I mention it's longer? ;)
Now if you have comments about something more "official" on our site, let me know and I'll be happy to take a look at it.
We should see the big picture here.
This is a great framework for professional developers.
Wanna know why?
Because it will allow more non-developers, wannabe-developers and dumb people in general to create billions of broken applications that we, professional developers, will be called to rewrite later at very profitable rates.
Erik,
You are kidding me, right?
Are you seriously advocating putting database calls inside the page markup?
You betchya! We have some guidelines for samples/templates etc to make sure that all business logic is at the top of the page and separate from the UI code, but yes. ON THE PAGE! :) It's way too late for April Fools too. ;)
It's pretty simple. ASP.NET is too hard for certain people. Those people all go to LAMP. We would like them to have an option on WAMP. Done.
Diego, if I were a consultant, I would be thinking that (and said the same thing on Twitter already). :)
Erik, re: "WAMP". I don't think that means what you think it means. :-)
Windows - Apache - MySql - PHP/Perl/Python ( http://en.wikipedia.org/wiki/WAMP)
You are correct, sir. I just mean our stack. Though it does have Windows in it, so that's good. :P
Wow, Erik you are an absolute moron and you are the type of developer that I absolutely hate working with because you don't understand a damn thing about professional development. Are you freaking serious about those comments you just made? Are you seriously trying to dumb down something to that level simply because developers are out there that are too damn stupid to understand simple concepts such as Single Responsibility principle? I mean thats like Dev 101 shit! REALLY?!?!
To me the developers that need to use shit like this are the developers that need to find a job like flipping burgers so they can serve my ass some food! They need to get their retarded asses out of a profession their IQ obviously can't handle! Sorry for my sharpness but its the damn truth!! And due to the brevity and sharpness of my comment I am posting this anonymously! BAM!
I personally buy the ".Net needs its own PHP equivalent" argument, in the context of some 14 year old that wants to crank out a crappy World of Warcraft guild site or a non-developer who has been shoved into an sometimes-developer role at work (some poor intern/sysadmin being told to have the corp website's Contact Us form save stuff to a database so it can be reviewed later) - I totally get that. You allude to that audience in your comment above, but I don't see that kind of audience identification ANYWHERE on the linked blog post (which I'm aware you did not write).
When you put that kind of code onto an MSDN post on a blog geared toward professional developers - David's previous post was on "hacking the ASP.NET parser" - and boast about its ease of use without identifying the architectural drawbacks to the approach you're just asking for grief.
What's wrong with EF? It's dead simple. And even simpler than this horrendous sample.
I think there has been a lot of misinterpretation of this. As much as some professional developers may like to tell novice developers to shove off, that's a horrible way to grow this industry. No matter what we do, those developers are going to find someone who's willing to provide them with the tools necessary to shoot themselves in the foot. Microsoft.Data, and WebMatrix as a whole, provides them with a way to get the simple "I just want a page that displays products, and I want it NOW" cases finished, and still move forward to cleaner and better architecture.
Not to plug my own blog, but I'll do exactly that: http://tinyurl.com/29ht3th - You may disagree with my evaluation of the situation, but I think Microsoft.Data is actually more likely to start drawing novice developers towards better practices.
I completely get that you'd like people to have a PHP equivalent on Windows (in terms of ease of adoption, speed to delivery, etc.) Although if that's the case, I'm not sure why you bothered supporting PHP on IIS. But anyway...
Even given that, I just don't see it. Are you saying with all the smart people that MS does and can employ, you can't create a language or even a framework (internal DSL, whatever) that's both simple to understand, and reasonably correct? That the only way you can all think of to make development simpler is to shove everything in one page and say "write SQL as inline literal strings!"
What a terrible paucity of imagination. I spend my time trying to bring people up, to show them safer, simpler, better, more manageable, more testable ways of writing code. Then MS comes along and says "to hell with that - just get it out of the door! If you don't want to bother with all that tricky stuff, just ignore it - we'll help!" Wrong direction. Just appalled. If you don't want everyone to have to deal with complexity create something better. Don't create something worse.
Microsoft.Data - thanks. Embarrassed to call myself a .NET developer again. Seriously, WTF?
@Eric - If I remember correctly you were responsible for the original oxcite debacle, therefore your comments here are understandable. Your recent move to a pm role is a good one, for all of us!
With Linq-to-SQL and EF, I'm having trouble seeing why anyone would be doing this. Assuming that you dragged the tables onto the DBML designer (and since they're using SQL, the audience for this product ought to be able to figure that out), the code becomes this:
@{
var dc = new NorthwindDataContext();
var query = from p in dc.Products where p.UnitsInStock < 20 select p;
}
@foreach (var row in query) {
@row.ProductName @row.UnitsInStock
}
Dirt simple with compile time checking and no chance of SQL injection. This problem of a rapid DAL has been solved. Maybe I'm not getting it, but all the smileys in the responses aren't making us feel any better about this kind of stuff.
(disclaimer - I'm not involved in this api - but I do know @davidfowl and he's a great guy.)
If I had to guess, part of the thing could be in the interest of illustrating one concept at a time - the .Open and .Query methods, and how they iterate. The value 20 is hardcoded, not an input-string-concat, but you could say it's also a good place to show how a sql parameter would be used to avoid string concat.
Same with using razor in the loop, which would htmlencode @product.ProductName @product.UnitsInStock by default... But I'm guessing again the example was to illustrate row properties w/out explaining that feature of the view engine.
As far as putting a query in a view, yep... I'd agree you won't want to weave them together in practice - learned that doing my share of vbscript/asp back in the day (and have even bulldozed "on error resume next" in a few pages that had a tendency to produce runtime errors - I know - bad me - but it was a long time ago and stopped the page from stopping halfway down with a ado db error).
But I don't think that's what he was showing - the point of the sample seems to be "when you loop over a query the iterator has these properties" more than some structural guidance. Maybe Console.Write would have been better than Response.Write...
Though, @diago, not sure if you were being ironic or not, but there could be a really interesting observation in that statement... How many household-names-of-the-internet started with a handful of wannabe- non-developers patching together "hello world" grade php script to light up a cheap domain name? Long since rewritten in a modern and disciplined fashion, but incrementally, and obviously remaining on the lamp stack.
I don't know what people expect from a company whose idea of innovation is to ask Mergers and Acquisitions to gobble up all the start-ups they possibly can.
++ to Diego's comment. Right now I am working on fixing what was obviously a 'cut and paste the worst Microsoft samples you could find on the internet' job, like this little gem right here:
Ayende, I don't think he's proposing a ORM framework or that kind of thing. It's just a simplification of ADO.NET API, for whoever still using it. It leverages dynamic language capability in C# to reduce the syntatic noise that was previously present in ADO.NET API (those clunky DataReader, DataTable, DataRow, etc).
If you compare this API against ADO.NET, this is a great improvement. Of course you can't compare this with ORM solutions.
Go directly to RoR. There is a simpler way, folks. Unfortunately, it's just not a .NET product.
I am not sure I would go completely apesh!t about something like this; it has it's uses when you need something done really quickly and crappily.
The LAMP argument is legitimate in that drupal/wordpress have attracted so much attention and developers the last couple of years...MVC.NET came out 4-5 years to late and the momentum has switched to other 'simpler' frameworks. MS is just catering to the demand...of course way to late.
From what I have seen lately, management and business are wondering why we (asp.net devs) don't use wordpress for everything; wordpress has become a pop culture phenomenon...and no, they don't really care or understand about architecture.
Thank you Microsoft for affirming my decision to dump your ecosystem and move to OSS for my new startup.
That you can still come up with this crap in this day and age.
Also, Northwind immediately tells me I'm about to see something crap and ugly.
OMG, now I'm sure that ROR was one of my best tech choices.
I keep waiting for an update to the original article saying it's a joke or an April Fool's joke accidentally unveiled early.
PHP rules the web, fair enough.
The idea behind Razor is good but I have to say that Ayende is right. I don't care about "response.write", but more about inline SQL strings. I also agree with Mattmc3, EF already does a far better job. So why not combine the two?
Allow dynamic inference of an entity model, something like:
using (var db = Database.Open("Northwind"))
{
@foreach (var row in query) {
@row.ProductName @row.UnitsInStock
}
}
That's ridiculous!
I kind of agree with Diego that apparently they are targeting a bigger market with dumbed down development to appeal to the masses.
IMO, they should move some EFers into that group! :-)
Architecture guys. Get off your high horse, just because you use a layered or MVC design of some sort does not make you a better human being than a scripter. Your attitude is appalling.
To David Fowl and Erik Porter: I can see what youre shooting for, and your intentions are genuine, but when it comes to very basic cheap sites, ASP.NET is too expensive, it is like killing fleas with atom bombs.
Let the simple sites be handled with simpler frameworks like cakephp, turbogears, web2py, django, heroku etc etc etc... they are much lower overhead and better at making small simple sites. ASP.NET is better geared for larger endeavors.
The problem is that Redmond keeps on coming up with new data access stuff far too frequently. Why are they so obsessed with data API's?
Maybe they feel the need to keep releasing such new stuff to make up for lost time? Point in example: we are in 2010 and Microsoft has just got round to pushing out a decent MVC (v2) framework for .NET -- we had this stuff in the Java world 10 years ago.
Maybe I am just getting too old...
@Erik Porter
I don't know, but why is using a simple o/r mapper like Linq to Sql a bridge too far for the target audience you are aiming at? If that's the case, I'm sorry but everything else required to build an application is then also out of their reach. Your code with Linq to SQL:
@{
}
I don't know but... is that really that hard? If so, sorry, but that person shouldn't do software development and should get the f. out of my profession as it ruins the title 'software developer' for everyone else.
Writing software isn't equal to flipping burgers at MacDo. It requires logical thinking and knowledge of the material you work with. If one doesn't spend that little effort to learn that, the results will just be bad. But what's worse: the client can't judge that and pays likely top-dollar for these crufty 'projects'.
THAT's what annoys me the most: that these wannabe software developers convince their clients that they can deliver quality, but instead just trick their clients in paying way too much money for what's delivered. Which gives others, who DO know what they're doing a bad name too.
I agree with Oren here, why was this a good way to spend MS' resources? I don't see it. Writing such a wrapper takes a day or two, hell, most programming books about VB.NET or C# contain a chapter with the code for these kind of wrappers.
Those of you who are worried about SQL Injection attacks are being stupid. Sure you have to escape your parameters or risk danger. But you have to do that anyways or the query will fail if someone includes a single-quote.
@Frans Bouma
Not everyone is a SOFTWARE DEVELOPER. Some people just want to make a little site to keep track of their model boat club's meeting schedule.
I don't know where to even begin discussing how wrong you are.
@ Ayende
I don't mean to be rude, but I have to wonder how long you have been programming.
Long before we ever thought web sties, let alone SQL Injection, we still had database access. Back then we all knew that we had to escape our strings so that something like "Joe's Fishbait" wouldn't cause the query to bomb.
What makes you think it is any different today?
Gentlemen, gentlemen-- calm.
WebMatrix is absolutely not intended for people who read this blog i.e. professional web developers.That is why you don't like it. It is not for you. Not even for people aspiring to be you. Not even for you before you became a decent programmer :)
It is intended for the women I know who runs a rugby website for her local team, it is intended for my friend who is a chemist but wanted to gather some data on a web page from colleagues, it is intended for my son to create a page that does something just a little more than HTML.
None of these people are programmers.
None of them want to be programmers.
They all want web pages that "do stuff".
In short - what a lot of PhP is used for and indeed to some extent classic asp.
It is just too much to ask those soft of people to get their heads around ORMs etc. Its just too many "things to learn"
Jonathan,
Depending on how you want to could it, I have been programming for 11 years or 16 years.
And escaping strings for SQL is a fast way to SQL Injection.
There is such a thing called parameters, you know
Arrogance diminishes wisdom
@Jonathan
"Not everyone is a SOFTWARE DEVELOPER. Some people just want to make a little site to keep track of their model boat club's meeting schedule. "
ah, so they're downright incapable of using simple tools yet are capable of understanding how MVC works, how these render engines work and how databases work, what SQL is, etc. etc. ?
I don't buy it. People who want to create a simple site for their stamp collecting club either can do that themselves all the way or can't do it at all, there's no middle ground, as to BE there on that middle ground, requires already so much knowledge that to get THAT knowledge you already have to invest so much time, it's too much work. Why not simply use frontpage or what have you these days to create a simple website. Most ISPs offer a web-oriented editor to quickly setup a site.
I mean, using MVC with the render engine Erik Porter showed above is already knowledge you gather only with knowledge how to create programs already. So the argument that these people apparently all know that without making errors (and know how to fix them!), know how to create html etc, how to write SQL queries, but are clueless how to use linq to sql is IMHO silly: it doesn't add up.
I genuinely don't understand the basis for some much of the anger and nastiest in the comments left here. Everyone seems to think here that their thought path is king and everyone needs to fall inline or their IQ is low and they are dumb (A gross over-simplification of the statements made here).
@Frans - It doesn't have to add up to you. Good for MS for letting developerings decide what styles and what tools they like best. Like it or not, folks comfortable w/ PHP may become interested in .NET thanks to Razor. Chances are you're right and once they're part of the MS conversation, they'll understand more (with respect to the MS stack) and perhaps give-up preceived no-no's like inline DB calls.
@Eric Nelson - I definitely agree with the "too many things to learn" statement. If I'm a beginner or even an expert on another stack such as PHP and stumble upon WebMatrix, I'm definitely more interested in the first 30 minutes if I feel like I can digest something. I can incremently learn about ORM's, MVC, and suggested patterns/practices as I get comfortable with the item that first caught my attention.
Although I do not see a use for this code for pro developers as they will of course use a proper ORM tool I see Microsoft.Data fit nicely into the webmatrix product. Webmatrix is being created to get more perople into .net so you have to support their crazy php programming styles. Not everyone is an expert and many don't care to improve themselves which might even be a logical decision for them. I think many comments here are missing the context.
How would I create my DAL in such a way that I could easily replace NHibernate with Microsoft.Data? Repository pattern?
Sorry. I couldn't resist.
Folks, this is ugly code. You can't deny that. Personally, I haven't decided if I buy the whole "hobbyist market" excuse.
I know several "professional" programmers who currently live in Dataset land and who would rather use this stuff than to invest an afternoon watching Summer of NHibernate.
This api supports parameters: db.Query("select * from movies where year > @0", 2005);
It kinda looks like the ado.net wrapper I build for a database-update tool.
I think an "upgrade" to straight ADO, leveraging some C# 4 dynamic features, is a useful thing to have in a bag of scripting tricks. There -are- such things are one-off throwaway apps for which an ORM [or L2S] is a poor choice.
Unfortunately, I think David's post does a poor job of promoting the new features. Ayende is right that many of the people this library is aimed at will come across that blog post and copy/paste it into their code, thereby perpetuating a litany of bad practices. I'm all about making ASP.NET more approachable for students and newbies, but let's at least -try- to teach them properly in the process.
In short, my verdict on Microsoft.Data is "meh, could be useful in certain situations, but not a game changer". My verdict on the way it was presented in the blog post: "No, no, no...."
@James Alexander
"@Frans - It doesn't have to add up to you. Good for MS for letting developerings decide what styles and what tools they like best. Like it or not, folks comfortable w/ PHP may become interested in .NET thanks to Razor. "
Why on earth would a PHP developer switch to .NET? PHP has massively more ready-to-rock frameworks, examples, code snippets, books out there, and above all: hosting a php site somewhere is cheaper, as linux based hosting is often cheaper than windows hosting (and also more common).
I'd expect a PHP developer, IF ever, would switch to ruby /RoR instead of .net.
"Chances are you're right and once they're part of the MS conversation, they'll understand more (with respect to the MS stack) and perhaps give-up preceived no-no's like inline DB calls."
Don't be naive. A bad habit is hard to lose.
Sjaaky above says Microsoft.Data supports parameters. Explain to me why someone who has no clue about development (as that's the target audience!) would opt for a parameter construction (if he already knows wtf a parameter is) instead of in-line hardcoded values or a string concat? You only opt for parameters if you know what sql injection is. That requires knowledge of sql above the level of 'no-developer'.
The library itself isn't so bad. As others have so often mentioned, everyone and his brother has written a wrapper around ADO.NET. So one could argue that this was a waste of resources to "officially" develop one, but a bad library it is not.
However the root of the problem lies in the promotion of sub-optimal programming practices, as describe in the blog post and heavily supported by certain followers (even other MS employees!) It doesn't particularly matter how new you are, how "not-professional" your project is, or how fast you want it done. There is no excuse for writing poor code.
Imagine if the world of electricians worked the same way software engineering does. No electrical codes, no required proficiency tests. Just because I can get into my electrical box and screw around with wires and cables and through trial/error make it work, doesn't mean it was ever a good idea.
Dangerous practices are dangerous, no matter the situation. Eventually a "professional" will ALWAYS have to go back in and fix what the "amateur" screwed up.
Some people don't like this style of API - fair enough, but if Microsoft decided to provide this API anyway for those that might want to use - why add yet another API - What about Data Access Application Block in Enterprise Library?
What's all the fuss about? It is MICROSOFT.Data.dll - when it makes to SYSTEM.Data.dll, then start panicing.
"ah, so they're downright incapable of using simple tools yet are capable of understanding how MVC works, how these render engines work and how databases work, what SQL is, etc. etc. ?"
The problem is that getting started with all that is too much of an initial concept count. Did you learn all that up front? Probably not. Like many good quality pro devs today you probably started with something simple doing console apps, maybe later with a GUI, then you learnt about DB's and SQL, web pages, security, MVC. Along the way you picked up OO, good design and maintainability.
You can't start with all that, the learning curve is too great.
PHP has a very low concept count which is one reason why it is enticing to new devs. They don't have to learn an ORM, OO, design patterns, MVC etc. They start with a HTML page and then drop some dynamic elements in using basic logic.
Sure they'll make mistakes but they start somewhere.
I believe this is what WebMatrix is aiming at. Not at converting PHP devs but providing a simpler form of ASP.NET so people getting started have another choice.
[)amien
While I won't say parameters aren't nice, for a lightweight database like SQL CE all they do is save you the effort of writing
value.Replace(quote, quote+quote)
.I honestly don't understand the utter terror of SQL Injection some of you have. Even when working with raw strings it isn't that hard to prevent it.
@Troy Ok, wow. I didn't realize MySQL is screwed that up as well. Is there anything MySQL doesn't do wrong?
@Jonathan: They also help with culture-aware apps. Sticking a string version of a datetime into a SQL string yourself can cause it to be misinterpreted entirely - e.g. a UK user of your web app uses your date-picker - you have the right DateTime object in memory but ToString formats it as 1/7/2010 instead of 7/1/2010 and SQL happily accepts it (this happens because web.config allows you to make the current thread culture align to their browser language-accepts).
This also affects numbers (some cultures use , as a decimal opint separator)
[)amien
Despite many people's tendency to assume that WebMatrix was built because Microsoft thinks devs are dumb, I believe it actually has a noble cause in mind.
There are scores of developers that are flat out ignoring ASP.NET MVC due to perceived complexity, and a large part of the .NET community acting as naysayers and continuing to advocate WebForms because they believe it is an easier model that developers are already used to.
I think Microsoft is smart, and would love nothing more than to sunset WebForms and focus its efforts and resources into MVC so that they only have one solid Web Framework to maintain and enhance.
However, before they can even consider sunsetting WebForms, they have to nullify the MVC Naysayers and change the perception that MVC is too complex. WebMatrix is their first attempt at doing so.
Those of us whose first instinct is to assume MS built WebMatrix for the advanced, MVC-supporting, developer would do well to keep all this in mind. We should quietly accept WebMatrix as a necessary evil to keep new development projects from choosing WebForms over MVC and nullify the complexity argument.
@Damien:
"The problem is that getting started with all that is too much of an initial concept count. Did you learn all that up front? Probably not. Like many good quality pro devs today you probably started with something simple doing console apps, maybe later with a GUI, then you learnt about DB's and SQL, web pages, security, MVC. Along the way you picked up OO, good design and maintainability.You can't start with all that, the learning curve is too great."
I started with Assembler and so on. The thing is that there's a contradiction: to be able to use Microsoft.Data, you already have to know a couple of things. When you know these, you already have invested a lot of time to learn them, and my question then is: why is it accepted that these things are a prerequisite (as you can't create a webpage without it) but it's not accepted when Linq to sql has to be used.
Mind you, Razor might look simple but it too has quircks and edge cases and a learning curve, so does SQL. All that together is needed to be able to use Microsoft.Data. So you already have a certain level of dev experience. WHY is it then suddenly 'too much' to learn linq to sql?
"I believe this is what WebMatrix is aiming at. Not at converting PHP devs but providing a simpler form of ASP.NET so people getting started have another choice."
What does 'getting started' mean here? A complete novice, new to programming, seeing a piece of code for the first time? No. A starter with ASP.NET? Perhaps, but then it is really really bad: bad practises. So IMHO a 'starter' means something in between, but then again the question pops up: linq to sql was too much, but all that other stuff wasn't.
Or, was it because Linq to sql has to die and the only alternative was the EF which is 'too complex'?
Jonathan,
No, they don't. There are multiple ways to go around that.
I think this is the new tool, called lighswitch
www.zdnet.com/.../6981
I see both sides of the coin here...
.. but playing devils advocate:
Whilst we should be professional and aim for a good solution, we are all guilty of "over valuing" code.
We take onboard the current best practises, implement them to the best of our ability, then get dumped on from a great height as the underlying concepts become taboo. This seriously brings into question the "Maintainability vs Code Depreciation" equation.
We live in a disposable society, stuff like this enables throw away code.. IMO not necessarily a bad thing, you don't buy a newspaper that will last a millenium, in the same way you don't buy a car that is obsolete tomorrow!
For those of us old enough to remember, we spent years pondering the best way to future proof COM apps, carefully crafting interfaces, building layers of abstraction all in the pursuit of an elegant LONG LIVED solution. Do we continue to ensure those apps work? Sure.
Do we at some point just scrap them, and with the DOMAIN KNOWLEDGE gained rewrite them in far less time than we did originally, using some .NET / Java / RoR / ____ tools?
My feeling is I don't think computer science has yet modelled the "real world" correctly (will it ever?), and as such we are still hunting round, bouncing from idea to idea, framework to framework.
Personally I'd like to see lifecycle management of objects (I'm talking realtime cradle to grave stuff here rather than IDisposable/ AddRef()/ Release())
I see mildly typed object persistance combined with workflow frameworks taking us closer to this goal, in which light. the whole question of Microsoft.Data becomes moot :)
Si
C'mon guys, MS .Net ecosystem is losing so many developers to more worthy platforms (RoR) and languages (Ruby, Clojure) etc. MS has to try its best to poach developers from other platforms. And it can't dare to think of converting RoR or Clojure developers to .Net, so this is what they've stooped to; pathetic.
With all the negative comments around the apparent weaknesses in the code example I decided to write a more "enterprise like" implementation of the raw ADO.Net example for reference, and post it on my blog here:
h30507.www3.hp.com/.../81821
There's really nothing wrong with the code in this post. If you come from the PHP side of things, THIS is how things are done each and every day and how even big applications are built. People in that universe don't spend hours trying to create a monstrous Entity Framework model just so they can get one freakin record out of a database. There's a reason classic ASP was on par with PHP then it fell way behind once the .NET complexities started creeping-in and piling-up. Microsoft is finally recognizing that when it comes to web dev simplicity wins, period.
Web Monkey, eat your bananas. We are driving porsches meanwhile.
I think there is a fundamental reason why we have php developers.
php was rather easy to grasp - in the same vein as classic asp
the hosting is dirt cheap and runs on ISP's using Linux that is dirt cheap
Changing .net language and introducing 'simplier' constructs doesn't really address the core of #2.
Allow php to run on Windows does solve #2 either.
I don't think the real argument is PHP devs need simplier asp.net. I don't think 'wordpress' and 'phpnuke' and those php solutions were built by developers not capable of writing asp.net.
I propose if your asp.net could run on Apache without mono (ie. my host won't install it anyway - I tried), then you'd have more adopters.
Most of these LAMP guys do it because it's cheap and it runs anyway.
So, rather than keep delivering 'webmatrix', 'microsoft.data' and 'lightswitch' - let's start talking in earnest about running Visual Studio outside of Windows and deploying .net apps outside of Windows.
Then you'll get the crowd you must be seeking.
I strongly believe if I could, ie. develop with VS on a Mac/Linux/Windows box (not in VM), deploy directly to Apache - this would be lightyears ahead of trying to 'dumb down' the development tools.
I'd argue as well that MS has some of the simpliest and easiest to use tools now without needing to write sql select statements inside of a web page.
Web Monkey,
Actually, not at all. That isn't how modern PHP apps are written.
Concerns such as security, caching, etc are common in the PHP world.
Web Monkey - I'd agree that webforms was a cause of much woe. It's a pain to work with outside of a simple demo app - it's call to 'RAD' made it quickly easy to build crappy web apps - and the ajax attempts just bolted on more abstract and more painful to sift through code.
So I would agree that webforms probably pushed more asp devs away from .net.
If I was to talk to a php or web developer I'd be much more inclined to show them asp.net mvc vs. webforms.
If you hop out of the MS world for a few minutes, you quickly see all the big name frameworks are all mvc and using the same basic principles. Django, RoR, even the php zendframework. So, asp.net mvc is a step in the right direction. (although all of those I listed can run anywhere - asp.net can't - as I said before).
It's took Microsoft quite awhile to see they needed mvc - I was using Monorails before it and it was so much better than webforms.
But again, it's not the language - it's not even the framework - it's simple - for $6.95 I can get a php site up and running with mysql and practically unlimited bandwidth. Apache on Linux wins every time for the php crowd we're discussing.
@Damien Guard
I certainly agree with you on the other benefits of using parameters in SQL.
@Set: rofl? Is this a joke or real? Webmatrix is like WinFS at it seems ;-)
I don't normally jump into the middle of a storm like this, but I can't help myself with this one.
My three cents:
I agree that Microsoft's intentions are good, but also agree that they are misguided.
I believe these intentions are misguided because they are targeting a group that does not exist.
I base my assertion that the audience for this library does not exist on Eric Nelson's comment above:
"It is intended for the women I know who runs a rugby website for her local team, it is intended for my friend who is a chemist but wanted to gather some data on a web page from colleagues, it is intended for my son to create a page that does something just a little more than HTML. "
Where to start with this comment? I can't imagine how anyone who knows programming would expect rugby moms and hairdressers to learn enough about variables, flow control, inheritance, SQL language... just to get started. There are already hundreds, if not thousands, of web-based point-and-click brochureware website solutions online. Eric, do you honestly think the rugby moms will turn to Microsoft.Data before those?
I also take exception to the use of bad code for ANY example. There is just no reason at all to use crappy code "just for demonstration purposes." It's irresponsible and lazy.
Bravo to Microsoft for attempting to expand the audience for programming in general. Boo for a bungled, poorly promoted, misaligned, badly branded execution.
That is why is important to know what is the difference between a coder and a programmer. Besides, most of the bad practices you found out are because of Microsoft choices about letting the platform become more "accesible" for more people. Same happens in WCF, it is so powerfull framework, but provided with basic - fit all - templates, that most WCF implementations have bad perfomance and low security, because many coders got their hands on it, and never had 5 mins to improve their services.
I get the sense that this is akin to Smith & Wesson developing and releasing a new model of gun in which its easier to shoot yourself in the foot. (Given that someone is going to shoot themselves in the foot, how can we make doing it easier?)
Now I know where all the new fluff of .net was heading. Dynamic typing, prarallel extensions etc and all for:
trommelwirbel
Microsoft.data
I think professionals are always afraid to lose their bread and butter when programming becomes easier.
Look at Google Android App Inventor, well why Microsoft wouldn't do the same ? Target the mass.
The atrocious comments on this page are a perfect testament to the incredible ignorance of the asp.net web development community. You all want to top each others intellect but most of you can't even tie your F.....G shoes without help.
You can barely read, can't spell to save your life, know nothing about the world and can't communicate two sentences without sounding like a moron or a buffoon.
The problem is not the inline code for data access in WebMatrix which you could easily move to a class file, rather the pandemic of ignorance you have created with your personality, attitude, lack of morals and lack of manners.
George Carlin put it right when he said that in the U.S. it is like this:
"Garbage in, garbage out"
Terry,
I assume it is a joke.
I had a stroke when seeing the code and architecture there
@Ayende
People seem to like it :). The latest comments from May 2010 ask "Can we have the code generation template of your Data Access Layer?".
@Ayende
Can I ask why? A lot of people seem to like it, now does that make it right no. But I am curious to hear your thoughts.
Do you have a good example of a DAL?
Terry,
Take a look at the history of OR Mappers in this blog.
I talk about this frequently.
See these posts in particular:
ayende.com/.../...rchitecture-makes-me-flinch.aspx
ayende.com/.../...-generic-approach-will-fail.aspx
ayende.com/.../the-stripper-pattern.aspx
ayende.com/.../...-castrate-your-architecture.aspx
Darn we all sound like the old guy in the block that does not want kids running around in the neighborhood making all that noise, so we move into a kids free 55+ community.
Point is that these developers exist, and they will write code. They will make stupid mistakes, like we all did when we first started out, and they will THROUGH PERSONAL EXPERIENCE learn why DI and TDD and Separation of concerns, etc. are important principles.
Stop with the personal attacks and have a logical meaningful discussion. It we can't do that without personal attacks how can we call ourselves professionals?
@Ayende taking Erik's code out of context completely killed your credibility in this post. And then your weak defense was just .... well, lacking :)
I think, they read your comment Ayende, because the post changed and is now using parameter!
Comment preview