Wednesday, July 09, 2008

Philly ALT.NET - Thursday July 17 - Building Maintainable Apps with WPF

Next week's Philly ALT.NET meeting should be a good one, with our own Jon Graves talking about building maintainable apps with Windows Presentation Foundation (WPF).  He's going to touch on things like using the Model-View-Presenter pattern for TDD, Dependency Injection, and other patterns and practices he's found useful for building WPF applications. 

If you're interested in checking it out, send an email to rsvp [at] phillyalt [dot] net

Here are the details, which can also be found on our wiki at http://phillyalt.net

Building Maintainable Applications With Windows Presentation Foundation
Jon Graves
Thursday, July 17th, 2008
6:30 PM - 8:50 PM

Drexel University
Rush Building Room 014 (Basement Level)
30 N. 33rd St. (33rd and Cuthbert)
Philadelphia, PA 19104
6:30 PM - Greetings and Eatings
7:00 PM - Topic Discussion

Topic Abstract:
We will be exploring a simple desktop client application built using pure WPF that integrates XAML into the Model-View-Presenter pattern. Topics that may be touched on include: Databinding (way better than the crappy WInforms binding, trust me), IDataErrorInfo support, Dirty Checking integration, the Autofac DI framework, and the Caliburn WPF framework.

Jon Graves
Jon Graves is a Software Engineer who has been working with C# and .NET since before they were cool. Currently he is working at Neat Receipts, a document-management software company based in Philadelphia. He has a passion for designing and building stellar user experiences. When he's not coding, you can find him scuba diving, playing piano, or drinking beer. Usually not all at the same time though.

Tuesday, May 20, 2008

F# and Functional Programming at Philly ALT.NET Wednesday Night!

Just a quick post to get the word out that Matt Podwysocki will be leading the discussion at this month’s Philly ALT.NET meeting about Microsoft’s new .NET functional programming language, F#.  The meeting is on Drexel’s campus in the Rush Building, with food and meet & greet starting at 6:30pm, and Matt kicking the discussion off at 7pm.  We’re expecting a few of our friends from the local Philly Lambda group, too - should be a good time.

Details can be found on the wiki.

P.S. I’ve got DevTeach and Philly Code Camp wrap-ups coming soon, if I can get enough focused time to finish them!

Tuesday, April 08, 2008

BDD: Coming to a Theater Near You? (Tonight!)

By a stroke of luck, I’ll be talking about Behavior Driven Development twice in April.  The first occasion will be at the Northern New Jersey .NET User Group (aka N3UG).  Many thanks to Dave Laribee for the referral.  The meeting begins at 6:30pm.  Directions and more information are available on the website

On Wednesday, April 23rd, I’ll be talking more BDD at an ALT.NET-themed meeting of the main Philly.NET User Group.  The "headliner" for the evening is fellow Philly ALT.NETter Jeff Deville, who will be speaking about the new ASP.NET MVC framework.  It should be a lot of fun.  The meeting begins at 5:30 and is hosted by Microsoft at their Malvern office.  If you are planning to attend, please register, which helps them ensure there will be enough food, seats, etc!

UPDATE:  I'll also be talking BDD at PhillyNJ.NET on April 30:  http://phillynj.net

Other Events To Note:

Philly ALT.NET Pub Night - April 16th: Pub Night returns to Philly ALT.NET, and we’ll be back at Chaucer’s to eat, drink, and make geeky. The last pub night was a lot of fun, so make sure to check it out.  Chaucer’s has great food and drink specials from 5-7pm, too!

ALT.NET Seattle (SOLD OUT) - April 18-20:  I had a small part in helping organize the second ALT.NET Open Space coming up in Seattle.  Dave Laribee led a group of organizers, and it promises to be a great conference.  Unfortunately, the (free) event is full, so we can’t accept any more registrations, but hopefully I’ll have some stuff to blog about upon my return (having the time to actually write the blog posts is another issue).

DevTeach Toronto - May 13th-15th:  I’m really excited to check out DevTeach, which has a reputation as one of the best technical conferences around, and happens to be focused on .NET and Agile.  Many of the ALT.NET illuminati will be speaking, and I hope to learn a lot and make some new friends.  If you are thinking of registering, feel free to use Philly ALT.NET’s $50 discount code: PA0000ALTNET (Note: there are some great pre and post-conference sessions that you may want to check out, but be aware that you can opt to attend only the main conference, and save some money!)

Hope to catch you at one of these places in April or May!  Don’t forget to sign up for the Philly ALT.NET mailing list to keep up to date on our future meetings.  In May, we are looking forward to having Matt Podwysocki talk to us about F# and Functional Programming!

Monday, February 18, 2008

MVC or MVA? Or, What Do Controllers *Do* Anyway?

I've been looking at and working with Model-View-Controller frameworks off and on for a couple years now, from Rails to Monorail to ASP.NET MVC.  I've been taught that the Controller is a first class citizen, responsible for application flow (at least handling request/responses) and rendering views, etc.   The Controller gets its name in lights, right next to the Model, and the View.

But what does the controller really do?  By far the most popular pattern is for controllers and their actions to map to URLs such that /people/list maps to a PeopleController's List() method. So, are controller's just "Action aggregators?"  Are they basically namespaces for URL pattern matching (i.e. /[controller]/[action])?

While this was probably not the original intention for the pattern, in practice it seems to be the case.  Further spark for this line of thought for me was hearing JP Boodhoo describe how he implemented a simple MVC framework that was basically a Command Pattern.  JP's implementation matched requests (url + payload parameters) to a command, which handled the request and, if necessary, to a view that would render the results - bypassing the controller completely.  Monorail's Dynamic Actions approach this pattern by creating Action objects, that can be indexed to an action name in a controller:

public class MyController : Controller
{
public MyController
{
DynamicActions["index"] = new IndexDynamicAction();
}
}
The Controller/Action paradigm also brings some baggage when it comes to actions that are similar or shared across several controllers.  Controller inheritance can get real ugly real fast.  Hammet and others have sung the praises of Dynamic Actions to alleviate some of these issues, but to me, it begs the question, "why not just throw away controllers altogether?"

I wonder why we don't just focus on the Routing infrastructure to map requests directly to Actions and Views, which are the real "players" in the system.  This would allow for easy Action reuse, aggregation, inheritance, etc - all the benefits of the Command Pattern.

When I get a chance to get back to some real coding with any of the MVC frameworks I've used, I hope to experiment with this and see what I can come up with. 

In the meantime, I'm curious to hear other people's ideas on the value (or lack thereof) of the Controller in MVC?

Tuesday, March 11, 2008

(More) Kudos to the ASP.NET MVC Team

Before I sound too much like a fanboy, let me make it clear that I'm disappointed that the 2nd preview of the ASP.NET MVC bits doesn't offer significant improvements in testability.  But, it is clear that they had some other major refactorings to work on, and there were some valid reasons for their prioritization.  I have a post in the queue that was going to discuss the advantages and disadvantages of working with commercial (esp. Microsoft) products vs. Open Source products, and some of the points in favor of OSS were frequent releases/updates and the ability to dig into the code, understand and change it.  Well, MS keeps taking small steps toward evening the score. 

Two things that came out of interviews and announcements at the recent MIX conference are really interesting, and should be viewed as positives to those of us who struggle with the OSS vs. Microsoft debate at times.  Phil Haack mentions both in his recent post, Thoughts on ASP.NET MVC Preview 2 and Beyond.

1. Phil mentions that he had his team take a break from building features in MVC and had them actually build some applications with it.  Phil says he has been doing some of this himself, and hopes to do more.  He admits that building real applications, rather than focusing just on building a framework, has really helped him understand the testability pain points that exist in the current release of MVC.  I think this is huge.  It is often stated that good frameworks (and patterns and architectures) are not designed, they are "harvested" from real applications.  It's hard to design a framework in a bubble and get it right.  Microsoft has struggled with this over and over again, as they are building platforms and frameworks and trying to satisfy as many scenarios and customers as they can, before those customers have even built anything real with the product.  No matter how much it may frustrate those of us waiting for a more polished MVC framework to be released, it is a great idea to stop building, and try to use the product as-is in real apps on a regular basis.

2. Scott Hanselman announced that MVC will be "dropped" via CodePlex in the near future.  My dislike of Team Foundation Server aside (I guess I'll have another go with SVNBridge), it is great to hear that the MVC team is shooting for more frequent releases, in buildable source code form.  This means we will have more frequent updates that we can build, and also we are allowed to "tweak" the MVC source code, as long as we are not re-distributing our tweaked source.  This is some sort of middle ground between a Reference license and an OSS license that Phil himself admits is sort of a "baby step" as MS feels out this new territory.

While it's often easy to be cynical and think that Microsoft is out of touch with "real" developers, way behind certain OSS initiatives, or that they aren't  doing (or can't do) enough to keep up - if you take a look at all of the smaller changes going on across the various product teams, there are a lot of signs of movement in positive directions that should be appreciated and encouraged.  While these may only seem like small breezes against the giant sails of the Microsoft galleon, if we are going to see the larger changes in direction that many of us hope for, it's going to start with small shifts like these. 

Thursday, March 06, 2008

Reason #94,532 to Hate SSIS

I've mentioned before my fuming hatred for SQL Server Integration Services.  And I'm not the only one

SQL Server 2005 gives us a fairly simple way to convert tabular data to XML using FOR XML.  In the query analyzer, you can actually click on the results and it will open up as a file which you can "Save as..."

So, wouldn't you think it should just be a cakewalk to export the results of a FOR XML query to a file as part of an SSIS package? 

WRONG!

There is no built in data flow component or data destination that will take the results of a FOR XML query and export to file.   In fact, there is NO straightforward way to do this at all, aside from manually via Query Analyzer.  I've found some info about custom script tasks, and using command line (SQLCMD or OSQL) but none are pretty. 

In fact, I tried the custom script task approach, and it worked fine locally, but when I tried it on my production system, there was some unicode issue with invalid characters and it wouldn't save.  Leaving me in an impossible situation, as I'm not SQL Server guru.

This is really just an absolutely inexcusable oversight for an "Enterprise" worthy database solution to make this so difficult. 

My future ETL processes for clients will most certainly use Rhino.ETL if at all possible, before looking at SSIS.  SSIS remains one of the worst tools I've ever experienced.

UPDATE:  I got this working late last night by changing the SQL from a straight query to a stored procedure and using an ADO.NET connection rather than an OLE DB connection.  I think the latter change was the biggest factors.  I have had other issues with OLE DB connections in SSIS.  I don't really understand, but in SSIS you often need to choose one connection over the other.  For example, OLE DB connections can not execute Stored Procedures, but ADO.NET connections can.  I still hate SSIS.

Sunday, February 17, 2008

HTTP Performance - Have you been watching?

I've been (finally) watching/listening to DHH's RailsConf 2007 Keynote while going through the stacks of paper that have grown beyond acceptable height in my office.  One of the things that really caught my attention was his discussion of HTTP performance and optimization and how it is built into Rails 2.0.  Having spent a lot of time optimizing page weight and other HTTP-related issues last year for my biggest client, I really learned the pain that ignoring this stuff can cause, contrasted with the value that a little bit of thought and work in this area can provide.

I really am due for a more in depth blog post on some of this stuff - I meant to do it back then, but probably set my sights too high for a "grandaddy of them all" post, and ended up never starting.  Hopefully I can break off a few bits and write some posts soon. 

The things that DHH focused on in that part of his talk may be some of the most ignored and underrated areas of web development (especially in the ASP.NET webforms world) in regards to overall impact on application performance.  In short, they are:
  1. Page weight - VIEWSTATE!  Did I scare you?  If not, check out the percentage of your page weight that ViewState constitutes, and you'll go running for mommy.
  2. Dependencies - Ever broken out Firebug or Fiddler and examined the number of secondary requests (images, javascript includes, CSS files, etc) that your pages cause?  Every one of those adds to your page weight, and the time it takes for a browser to render your page.
  3. Number of concurrent requests - Another little-acknowledged piece of trivia is that the major web browsers, thinking that they are helping preserve web server resources, only allow 2 requests at a time for a page.  So, if you are keeping your code simple by breaking CSS and JS out over multiple files, realize that they have to wait in line, 2 at a time, to be downloaded by browsers.  In other words, no matter how fast your users' connections are, they can't get around this.
Possibly the biggest and easiest way to affect this is to add HTTP Compression.  All modern browsers can handle compressed HTTP responses, and it's trivial in .NET to write an HTTPHandler in .NET to do this for you.  This was the single "killer feature" I added for my client, and it basically saved the day for their users with slower connections (and longer distances from their web server).  There are some OSS handlers out there already, and I may throw mine into the mix, as it does some things differently than others I found (at least back when I looked).   DHH mentions that HTTP compression is now built into Rails.

Another thing that is built into rails, which is something that I didn't do, but would be fairly easy in .NET, and probably a *huge* benefit, is to minimize the number of requests by multiple Javascript and CSS files into a single file for each, which means a max of 2 requests - one for all javascript includes, and one for all CSS includes.  That would probably have a great impact on your page load time.

I have some more thoughts (and code) around request/page performance that I need to blog about.  Hopefully DHH's keynote will spur me on to actually get some of this stuff out there.  In the meantime, get Firebug or Fiddler, and check out how large your pages really are, and how long they take to load from the beginning of the first request, to the end of the last (secondary) request. 

You may be in for a big surprise.
kick it on DotNetKicks.com

Tuesday, February 12, 2008

ASP.NET MVC CTP 2 - Awesomeness

Scott Gu has posted an updated roadmap for ASP.NET MVC.  After playing around with the first CTP for a bit (even beginning to incorporate it into a client project), I decided to put it aside for a while and wait for CTP.  Mostly due to the testability story not being quite where I wanted for use in a "real" app.  Not saying I was surprised - after all, it is a CTP - but I wanted to give it a shot. 

Now, a new preview release is due to be released in a few weeks (to coincide with MIX 2008), and I'm getting excited again.  You should read Scott's post for the gory details, but here are the things that I'm pretty stoked about:

  1. Drop-in DLLs.  You can just drop the MVC dll into your bin and reference it - no setup or GAC'd assemblies needed.  I kind of thought you could do this already if you just found the DLLs the installer GAC'd, but I can't remember if we tested on an computer that didn't have the install.
  2. Improved Routing.  Routing was pretty cool in the first CTP, but was a little *too* simplistic.  Things like REST were not supported out of the box.  Sounds like Routing is getting some first class treatment, making it a stand-alone library (usable outside of MVC in other ASP.NET scenarios) and enabling more robust routing options.  This is key for an MVC framework.
  3. Filter Attributes Added.  Monorail has pretty nice support for controller filters, such as "before action" and "after action" interceptors.  MVC CTP 2 willl have these, and ups the ante a bit with supporting filters right on the actions themselves, something that isn't available out of the box with Monorail (filters are added at the controller level and apply to all actions of that controller unless you place a SkipFilter on an action). 
  4. Refactoring.  Sounds like they've put some more work into the design of MVC to allow easier extensibility, pluggability, and perhaps most importantly, testability - especially of controllers.  Looking forward to playing around with Controller Factories, and perhaps implementing something closer to Monorail's Dynamic Actions, to streamline my controller setup. 
  5. Downloadable/Patchable/Compilable Source Code!!  That's right!  They are going to drop the source, and let us monkey patch [update: Scott corrects my usage below!] hack our hearts out.  This is AWESOME.  I can see myself losing days on end digging around in there, and causing myself all sorts of untold heartache.
Needless to say, I'm all geeked up once again for a new MVC CTP.  Who said Christmas only happens once a year?

ALT.NET Seattle - Registration open!

Registration *just* opened for ALT.NET Seattle - get in while the gettin's hot!

ALT.NET Seattle - April 18-20

If you're wondering whether it's worth your while - take a look at the participants page!  There are going to be some great developers there, and the Open Spaces format is a great way to get directly involved in conversations about anything that interests you. 

The Austin conference was the best conference experience I've ever had, and I expect no less in Seattle!  Hit me up in the comments if you're going!

Friday, February 01, 2008

Resharper 4 EAP in 2 Weeks!

Ilya, the .NET Products Manager at JetBrains, just posted that the EAP will be another couple weeks.  But at least he gives a hard deadline!  Can't wait...

ReSharper 4 EAP Will Start in Two Weeks