Friday, July 31, 2009

A Little Sugar for Your MVC

I've recently started using two new tools that have made ASP.NET MVC development just a little sweeter.

AutoMapper is a convention based object-to-object mapper. This sounds scarier than what it is. This just means instead of this:

Var instance1 = new MyModel();
  instance1.Property1 = instance2.Property1;
  instance1.Property2 = instance2.Property2;
  instance1.Property3 = instance2.Property3;

you can do this:

Mapper.CreateMap<MyModel,MyModel>(); //typically at a ‘global’ level like Global.asax
   Mapper.Map(instance1, instance2);

There is a perf hit, since it's having to do a little reflection to make this magic happen, but for many cases, this perf hit is negligible and acceptable.  It gets a little more complex, in that you can define type converters and other means to handle special cases or conversions from one type to another. There are examples on the site. The main place this is useful in a simple MVC business app is in updates where you typically go get an existing record from the db and then do that right-to-left code to set some properties before calling SubmitChanges().

T4 is a code generation tool that’s been built into VS since 2005. T4MVC is a T4 template to give you some syntax sugar in MVC. I've blogged about this before, but it's come a long way since then, including a link from the official MVC site in CodePlex.  It looks over your application, and generates code to help you do common stuff a little cleaner , more strongly-typed way. For example, instead of this:

public ActionResult MyAction(){
    return View(“SomeView”);

you can and should do this:

public ActionResult MyAction(){
     return View(Views.SomeView);

And instead of this:

<%=Html.ActionLink(“Text”, “MyAction”, new{id=someValue)%>

You can and should do this:

<%=Html.ActionLink(“Text”, MVC.MyController.MyAction(someValue))%>

The main benefit being, if your controller or action changes, then the 2nd examples will break the build, whereas the 1st examples you won’t catch until runtime.

Friday, July 24, 2009

Help Your SharePoint Users Help Themselves


This is just a quick and pretty obvious tip, but worth posting I think.  We recently rolled out a SharePoint solution for a customer and as an afterthought I added a Wiki called 'About this Site' to the home site.  As I identified areas in training that they might need help remembering, I added pages to the wiki with very short steps to do various tasks.  In addition, I showed them how to add their own articles.  Each took just a few minutes to add, and in the end, they had easily accessible documentation on their particular SharePoint install.  I wondered if they'd use it, but I was pleasantly surprised when I logged in and saw 'Last Modified by:' wasn't me!  SharePoint can be pretty daunting to new users, and even old ones.  By adding documentation using the customer's name and terminology familiar to the customer, we made the site much more approachable.

As a bonus, I was able to export the wiki as a template and can now re-use it elsewhere, though I'll need to take care to change the customer name everywhere as needed.  I may look into putting one of these up publicly and building up a generic reusable wiki templates to install as starting places for various common SharePoint scenarios.

This idea extends to non-SharePoint apps as well.  I'm trying this concept to document some ASP.NET MVC apps for customers.  Those haven't rolled out yet, but the customer seems to like the idea so far.

Wednesday, July 15, 2009

FogBugz 7 In-Depth Review From the Trenches

We've been running FogBugz 7 Beta for a while now, and with the official release today, can finally blog the experience. 

First, the bad. Our company bills by the hour, so tracking time is pretty important.  To avoid duplicating effort, we track time in FogBugz and bill using a report run directly from the database.  When keeping up with time using the 'Working On' menu, this works well, but if developers wait to put in time, or if it's not practical (ie when working on site), going back and adding time can be a real hassle.  FogBugz 7 has improved this somewhat by allowing you to search for a case when adding time - you used to have to remember the case number or go search.  Still, the whole UI for this just feels tacked on and not as well polished as the rest of the app.  A weekly timesheet would help, as would the ability to add cases in the timesheet UI.  Not a show-stopper, but something that still needs improvement IMO.


Where FogBugz really shines though is in managing the workflow of dealing with project management and bug tracking.  Built initially around Joel Spolsky's well thought out software project management philosophies, this app is well suited for Scrum, Lean, or other Agile methodologies.  Scrum in particular is made even easier with the addition of Milestones and true burn-down charts - in version 6, you had to re-purpose Areas for this.  But all of this is flexible enough that it should adapt to just about any methodology.  Below is my standard filter on a project - All cases, sorted by Milestone.  In this case, closed cases are shown, but you get the idea.  For larger projects, I filter down to a single sprint.


One small new feature I like is the 'case type' option when adding new cases.  These quick-entry cases used to default  to bugs (hence all the bugs in the shot above!), but now let you choose 'feature' from a little drop-down.  As in 6, FogBugz intelligently sets the Milestone or other properties based on where you click 'Add Case' from.  This comes together to make writing up a new list of feature requests blazingly fast.

Another big addition in 7 is subcases.  I think this has potential to vastly improve our workflow.  One of our constant headaches is the disparity between estimation and actual work.  We're generally fairly accurate overall, but often our clients don't want to see every single case we work on - they want to see a bill that looks similar to our original estimate.  For example, we may estimate 'Database design - 8h', but work 1 hour creating some tables, 2 hours on tweaking a data access layer, and then go back during the project refactoring the database.  In the end, we generally come close to the estimate, but it's scattered about 10-20 cases that the client doesn't necessarily see all fall under 'Database Design'.  By allowing us to add subcases, we can keep work in the same general tasks that we estimate.  One caveat here: estimates are summed  up, so adding a 1 hour task beneath a 4 hour one causes the 4 hour task to become 5 hours.  This is logical, but in our workflow we'd typically want it to subtract time from the original so that the entire tree remains estimated at 4 hours.  For now we'd have to do this manually. 


Finally, FogBugz 7 adds plugin support, with a full .NET API for writing plugins in Visual Studio.  Previous versions provided a REST-based API that allowed some interactions, but the new platform enables very rich customization. In addition, a plugin 'app store' gives you quick access to community plugins that you can very easliy download and install. Already, we have written several custom reports for views on tasks that we frequently need, and have several ideas on how we may use this to fit FogBugz more seamlessly into our environment.   The Plugin model has some of the best documentation I've seen for an API like this, including tons of full examples.  One of my favorite aspects is a Database Migrations framework which lets you version your plugin's database needs effortlessly.

However,the API reveals just how odd an app FogBugz is.  Written in a custom programming language developed by and for Fog Creek, FogBugz's code and API looks very much like classic ASP, despite now being a .NET app.   This roll-your own mentality peeks through in the API.  Fog Creek has developed their own MVC-like approach to the app, and this spills into the API model, where you are tasked with outputting raw strings of HTML and reading in request data.  Forget any RAD designer for plugins, or traditional Visual Studio tooling.  This is just you, pure HTML and HTTP GET/POSTS (with some important security restrictions).  The API does provide plenty of helper methods for building up your wad of HTML and keeping in line with the FogBugz UI.  Another area that works very much like classic ASP is the data access layer.  Instead of LINQ, Fog Creek has rolled their own query builder api for data access that is eerily reminds me of one we wrote for a project in .NET 1.0.  As a final nitpick - the naming convention is solidly stuck in 1982-style Hungarian Notation, with names like "CBug" and "sTitle".  Stepping back, though, it's hard to argue with success.  The API and app itself are very consistent, well documented, and work well. 

In the end, the awesomeness of it all makes up for it's quirkiness.  This the best project management app, made even better by some carefully thought out tweaks and all around faster performance. We've used FogBugz since version 5, and now when I see a company is using FogBugz, I can generally assume that they are going to have a good product and good customer service (FinalBuilder comes to mind).  I've tried several other project management tools and even considered building one, but in the end keep settling on FogBugz as the best available.   With a free 45 day trial, both on-demand and on-premise options, and very fair pricing, there's really no reason not to give it a try.

Tuesday, July 14, 2009

Azure Pricing Now (finally) Available

It's been a long time coming, but Azure's pricing model is now available

Windows Azure:

  • Compute @ $0.12 / hour
  • Storage @ $0.15 / GB stored
  • Storage Transactions @ $0.01 / 10K

SQL Azure:

  • Web Edition – Up to 1 GB relational database @ $9.99
  • Business Edition – Up to 10 GB relational database @ $99.99

.NET Services:

  • Messages @ $0.15/100K message operations , including Service Bus messages and Access Control tokens

Bandwidth across all three services will be charged at $0.10 in / $0.15 out / GB

This translates to a minimum of about $90 to $100 for a small single-server forms-on-data app in the cloud. This is very competitive pricing compared to Amazon E3 windows instances, which run about $1/hour and up, and comparable to low-end dedicated server hosting plans.  In addition, Microsoft is announcing initiatives to enable private cloud services via System Center and public cloud services by licensing and other efforts aimed at hosting services like MaximumASP.

Monday, July 6, 2009

An iPhone Sketch a Day - Week 6

 This post is part of an ongoing series about my daily sketches with a great little iPhone app called Brushes. You can watch my progress over on my Flickr Photo Set.

I cheated the past few days and instead of doing a new painting every day, I worked every day on a single painting, and posted progress to Flickr.  I'd hoped for some critiques and suggestions.  I didn't get as much feedback I'd hoped (thanks @real iDon't!), but this was an interesting progression anyway.  I still may go back and rework a bit, but I've submitted it to the Art-Mobile group.  Who knows - it may wind up being shown in Paris!

This week is Diego Velazquez in the Weekly Assignment group.  Valazquez is one of my favorites, so look for some in that style soon!

image image image image
image image    

FogBugz 7 Beta Rocking

We've been Beta testing FogBugz 7 for a few days now.  NDAs are taping my mouth shut, but (I think) I can say I like this version.  Setup was flawless, I've done a small project in it, and even toyed with the Plugin API.  There's a few things I'd like to see different, but I'm pretty sure this will be one of, if not the best software project management tools once it goes live.  Check-back after it drops for a more in-depth review and possibly some plugin goodness!