Scott Hanselman

Real World Apps in Days not Weeks

January 16, 2009 Comment on this post [26] Posted in ASP.NET | Windows Client | WPF
Sponsored By

imageI've given a number of presentations on ADO.NET Data Services (formerly codenamed: "Astoria") and I'm still convinced that if what it does fits your scenario, you can get a metric ass-load of work done in a short period of time.

Here's a real world example. A buddy of mine gives me a call and says he's been asked to do an application for a large clothing manufacturer. It'll run on the client machine and need to retrieve Apparel details over the web. He tells me he was thinking of using Web Services, maybe ASMX Web Services.

I asked him if it was primarily going to be CRUD (Create, Read, Update, Delete) type operations, nothing too fancy. He said yes, there'd be some sorting and filtering, but that'd be it. Should I write an HttpHandler and just return an Xml document? Some format I'll make up? he says. (Sound familiar? Kind of 2004, eh?)

Does it need an administrative console?, I ask. He says that'd be nice, but it wasn't spec'ed out. He figured this would be pretty low rent. The client even suggested (gasp) that they could just maintain a local XML file. After I threw up in my mouth a little, I made a few suggestions. ;)

Remembering that the goal here is for the solution to be simple, clean, and robust. It's also to under-promise to the client, but over-deliver. It's also worth noting my friend did a fixed bid for the work, so he just wanted to get it done.

We busted out the napkins and pens over lunch and scribbled some ideas, lovingly reproduced above in Paint.NET.

In about an hour, he described the Domain Model and we created a database using LINQ to SQL. We filled it with temp data and created a new Visual Studio Solution. We added a WPF app and an ASP.NET Website.

To the website we put in our LINQ to SQL .dbml so we had our Data Context. We added a new ADO.NET Data Service and hooked it up to the Data Context. I then showed him how he could query the entity model with HTTP calls. Then we moved based the browser-based examples and added a Service Reference to our WPF app and I showed him "LINQ to REST."

Next, we created a ASP.NET Dynamic Data website, but ended up combining it with our previous site, so we had a single ASP.NET website that was both a Dynamic Data site that also included an ADO.NET Data Service. The out of the box ASP.NET DD experience gave him a complete admin site that he'll wrap in either Windows Auth or ASP.NET Forms Auth - both things he already knows how to do as an ASP.NET developer.

We were able to get a nice working skeleton for his application in an hour. He used the ObjectDataProvider in WPF to bind the entities returned from ADO.NET Data Service to lists and combos in his client app. He got a free admin site that he can skin with CSS or change the markup to taste.

He's spent the last few weeks, on and off, going back and forth with the designer who wants the WPF app to look this way or that way, and he's changed the data model a few times, but the work in that first hour over lunch set the tone for his whole project.

Hopefully I'll get his client to agree to let me use the app as a case study or something and I'll be able to give you, Dear Reader, a LOT more detail about that first hour.

A reminder, also. All this stuff, everything we used ships today in .NET 3.5 SP1. We didn't use anything beta.

For now, though, here's some links:

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
January 16, 2009 7:27
A great case why LINQ to SQL should remain actively supported and developed - there is a problem domain it's perfect for. I love this example because the client and developer could focus on the WPF app and user experience, while the plumbing was just "done".
January 16, 2009 8:34
Exactly! I'm glad you "got" it also! It was a joy to work on this app.
January 16, 2009 8:41
Looking to see if a Silverlight client could be used I found this:
http://msdn.microsoft.com/en-us/magazine/cc794279.aspx

LINQ to REST looks neat!
January 16, 2009 8:53
The great news is that this type of application actually covers a VERY large percentage of the line of business applications out there. When Jas talks about the Practical Programmer - you just hit the nail on the head. :)
January 16, 2009 8:56
Some guy who makes 1/2 of what you guys make probably went back to his desk and created it in Lotus Domino in an hour.
tom
January 16, 2009 10:19
@tom, well i could probably recreate it in an hour in foxpro 2.6 for DOS too, but that wouldn't be any fun.
January 16, 2009 11:27
@Michael brought up Linq to SQL which was exactly what struck me when reading your post. I'm so gun-shy when it comes Linq to SQL after reading about Microsoft's "emphasis" on EF and non-commitment to advancing L2SQL.

Here's my case...we are not building a line of business application...we're re-building a VB6 "product" application into .NET. Our early work on that was built-out in using L2SQL. Development of that was fast and perfect for our needs. Then we read about the developments, or lack thereof (heh), surrounding it, and we're stuck. EF is something we've been experimenting with, but for our needs L2SQL was just a very nice fit. But we can't build out a product that needs to last (and sell) based on a core technology that's going nowhere.

Sorry for the rant, but it needs to be said. That said, great post and thanks!
January 16, 2009 11:43
Nice write up Scott!

FYI -
For folks using ADO.NET Data Services with Linq to Sql and/ or Sub Sonic I have written a couple of reference implementations of IUpdateable that are available on Code Gallery:

http://code.msdn.microsoft.com/IUpdateableLinqToSql

http://code.msdn.microsoft.com/SubSonicForADONETDS

(Note - the SubSonic implementation needs to be updated to the latest beta of SubSonic. Any volunteers?)


See the below post for the gory details on why this is needed - but the bottom line is you will need to implement IUpdateable if you want to use other DALs other then Entity Framework and you want full CUD (Create, Update, Delete) support with the Astoria REST head.

http://blogs.msdn.com/aconrad/archive/2008/12/15/what-is-iupdatable-why-should-i-care.aspx
January 16, 2009 12:22
Scott,

I enjoyed this post, thank you. I found it both funny (loved the "metric ass-load" and "throwing up in your mouth a little") and timely.

Many geeks are being let go from their employers in these finacially challenging times, but the fact is, companies and businesses still need software. The tools and ability to be able to produce software quickly are more important now than ever.

I note the comments about people using other techs could possibly do it quicker. Well, I would have to response with "who cares?" - This particular client wanted an ASP.NET app. They got what they needed in a relatively small amount of time.
January 16, 2009 12:24
oh my, within an hour... now that's efficient!! if only i can do the same for all my programming works within an hour.

a favorite of mine is still LINQ to XML (xml literal)
January 16, 2009 13:36
This is the reason I love Astoria. The first time you use it you might think that the entire LINQ provider for it is one big NotImplementedException, but when you get over that the amount of time it saves for simple apps like this is amazing.

If you'd done this in EF you would have spent more than an hour randonly clicking in the design surface trying to get it to map things the way you wanted ;-)
January 16, 2009 15:15

So, "Real World Apps in Days not Weeks", eh?

Then explain this line :

"He's spent the last few weeks, on and off, going back and forth"

Weeks, eh?

So what you're saying is that the easy stuff didn't take long? The hard stuff took longer (and I note that you don't even mention the time he spent with his client finding out what to do).

Perhaps metric donkeys can't carry all that big a load after all.



January 16, 2009 16:38
Hello Scott

Could you provide us with some more background info surronding the Linq2Sql vs Entity Framework debate?
Why can't the two 2 technologies co-exist, Microsoft has other overlapping technologies so I don't see the big problem.

ASP.NET MVC and WebForms are kind of overlapping technologies as well were MVC is the lean and sleak model (Linq2Sql).
What if Microsoft suddenly kills off ASP.NET MVC development??

I know the MVC team loves using Linq2Sql in their tutorials so I guess you would be in favor of keeping it around and continue evolving the product?
TT
January 16, 2009 18:12
So how many managers are going to say, "see they can write an application in an hour, why are you taking weeks implementing something called the repository pattern"?

Microsoft has always been pretty good with providing RAD with nice shiny drag and drop demos. However, part of the alt.net movement (which I am just starting to follow) seems to be to rebel against this sort of RAD approach. Ironically, going against RAD in some ways contradicts part of the alt.net mantra of "You aren't going to need it" (YAGTNI).

I'm not advocating one approach vs. another, this just seemed to be an interesting contrast to say Rob's MVC Store Front project.
January 16, 2009 20:42
When you are talking about quick to develop, I wonder - why would you pick WPF? Your going to spend 90% of your time trying to make some controls look cool - as witnessed by your other posts on the matter.

WPF still seams like the new kid on the block where it tickles the developers fancy but ultimately costs the customer more money. From what I experienced thus far and what I learned from watching Billy Hollis on DNRTV, there is a huge development cost for picking WPF over WinForms at this state in time.

What benefits are you getting out of using WPF for an in house app where a "wow" factor would get old quickly?
January 16, 2009 23:03
Jim Cooper - My friend is doing the development on the side, at night. He's got maybe 40 TOTAL hours into this. When I said that he's going back and forth with them over the last few weeks, it's over change orders and their unclear requirements, not because of any technical difficulty. Sorry if that wasn't clear.

Dave Tigweld - This app is (will be) a public application, running on the desktops of whoever wants to run it. I suggested WPF for a few reasons. One, the databinding in WPF is really easy and flexible. Two, I looked at the first comps/mockups for the application and it was clear that this was going to be a very stylized and animated application with lots of transparency. Doing this with WinForms would have involved a lot of hassle, while with WPF, my buddy and I were able to take the flash comps and get the same animations and effects in just a few hours of XAML markup. Also, WPF makes threading easy with its DispatcherTimer.

TT - Yes, look for some more info on this coming soon. I will try to get it all cleared up.

Andrew Conrad - Fantastic, thanks!
January 16, 2009 23:21
Wow! For a relatively short post, it was chock full of useful information. If you have any more architecture skeletons lurking in your closet, or on napkins, please share. I sometimes feel saturated learning the details of one particular piece of technology (or five!) and all the possible choices for getting them to work together, so it's very refreshing to see a high level reference example from a pro. Thanks!
MC
January 17, 2009 0:10
I have not looked at Astoria closely, so I'll say upfront this is an uninformed opinion. I generally like scaffolding assuming they follow the SOLID principles discussed in your podcast last week.

1. I honestly can't remember the last CRUD only app I wrote that did not have important business rules that needed to be validated. I know they exists, just haven't done one recently.

2. What did your tests look like. If did not have any, than you provided very little business value in the long run. Once a change needs to be made or a new feature introduced, you have no idea how it will impact the rest of the system. You've only shown that it works today.

3. What's the maintenance story like? If the behavior of the system changes, can I easily make those changes in a verifiable way (ie testable)



January 17, 2009 3:50
For folks looking for more info on Astoria, check out: http://msdn.microsoft.com/en-us/data/bb931106.aspx. The Astoria team tries to keep this site up to date with references to our latest content.
January 18, 2009 1:49
I'm awaiting "scaffolding/model support" for our beloved asp.net mvc project in RoR fashion :)

January 18, 2009 10:26
Steve - You won't have to wait very long...
January 18, 2009 19:20
There is something I always worry about which finally cause me to give up Microsoft's technology. Microsoft makes work easier, but harder to maintain. I use Link to SQL in one of my project, but soon it becomes slower even stops sometime as long as more use. After some research, I realized the limited capability on large database which I didn't know at the beginning.

This is not at complain. I just want to say we may easily misuse some new technology in production. In that case, more case studies are necessary for demo.
January 19, 2009 13:35
@John Walker - but what else do you need in L2S that is not already built-in, available as third-party libraries/tools, or can't be added as extensions? I'd like to liken the L2S vs EF debacle to Winforms/WPF. There will probably not be a whole lot added to Winforms in .net 4.0 because it is a mature technology. L2S is also very mature compared to any alternatives, which is why they need to focus resources on EF to bring it up to speed with what L2S can do today...
January 19, 2009 15:09
@Scott does that mean the next version of MVC that ScottGu spoke about a while ago is iminent? :-)
January 19, 2009 15:22
Scott

> My friend is doing the development on the side, at night. He's got maybe 40 TOTAL hours
> into this. When I said that he's going back and forth with them over the last few weeks,
> it's over change orders and their unclear requirements, not because of any technical
> difficulty. Sorry if that wasn't clear.

I had assumed that was the reason, as it is always the reason :-) And therein lies my point.

It is not actually all that impressive to have the database stuff working quickly, or a CRUD type UI for an app that has no business logic. They're the easy bits, and have been for decades now.

There are a ton of tools out there that would have gotten the same work done in the same sort of timescale.

I'll be more impressed if the code turns out to be maintainable in the long term. That's where the real expense and difficulty lies in writing software.
January 19, 2009 21:25
thanks
log

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.