Keep up to date with ongoing discussions and developer related information from the Blackfin team.
Portland Code Camp 2009
Portland Code Camp happens in just a couple of days from now - quite a few Boise developers will be making the trip out to Portland to present or just hang out. I’m presenting on ASP.NET MVC & Opinions - we will walk through building a sample app in MVC talking about the parts that you’ll want to add into the framework to make it more useful. If you're around, stop by and say hi...
ASP.NET MVC Opinionated Software

Out of the box, the ASP.NET MVC framework is very bland - it provides the hooks to add conventions and functionality, but doesn't provide much in the way of structure itself.  To get the most benefit out of it, you need to add in your own set of preferences, conventions, and behaviors.

In the book Getting Real by 37signals, this is referred to as "Opinionated Software."  Don't be all things to all people, take a stand on the features that you think are important.  In that light, here's a summary of some of a few of the things that I think are the most important opinions that should be added into your basic ASP.Net MVC project.  This is of course strongly founded on the work of others, modified here and there to fit the situation for a given project. 

No Magic Strings!

ASP.NET MVC relies heavily on dictionaries keyed by strings to get things done.  Using formCollection["name"] to refer to a value posted back is just asking for subtle & hard to find bugs later - when somebody changes the View ID to "firstName," for example. 

Another common scenario:  Html.ActionLink("linkname", "Create", "SomeController"); should be replaced with Expressions instead:  Html.ActionLink<SomeController>("linkName", c => c.Create());  You gain intellisense, refactoring ability, R# validation, and some limited compiling support if your code changes. 

Lightweight Controllers

In the MVC pattern, the Controller .. controls.  It receives an inbound request to do something (an "Action," like Create or List), and orchestrates both with Application Services to make that something happen, and the View that will present the result. 

The Controller does not do the work itself, because that would violate the Single Responsibility Principle (the Controller now controls/orchestrates, plus loops through a collection summing values, or generates an HTML string, or whatever).

Sometimes the line blurs between Controller responsibilities and Application Services responsibilities, but the guiding principle should be that the Controller does not do business logic.

Strongly Typed Views

This is related to avoiding Magic Strings... never bind your Views to a collection of Name/Value pairs.  It makes development more difficult and opens you up to a class of bugs that you could avoid entirely if you bind to a Model or ViewModel object instead.

ViewModel?

ViewModel != Domain Model

There is some confusion over the term ViewModel, thanks to the View/Model/ViewModel (aka "MVVM", or "I-Can't-Believe-That-They-Named-It-THAT" pattern).  In this particular case, I'm talking about something that is like your Domain Model, except is stripped down and simplified to work with a specific View.  But to the View, this ViewModel is going to be the "M" in MVC and fill all roles and obligations therein.  (This might be obvious to everybody, I hope so anyhow.)

Consider a View that shows some sort of table of Order data.  Perhaps you want to show the person who sold the order in this table.  One idea is to bring back a fully populated Order object, with the expected references to Users, OrderDetails, and whatever.  But, this could be a lot of data, and in any case it will be awkward to work with - what if you just had a slimmed down OrderView object, which exposes a SalesName (string) property?  Now its a simple projection from your fully-behaviorized Domain Model Order, to essentially a Data Transfer Object (except its not necessarily going over any wires).  The view becomes simpler, you don't have to clutter up your Order or User with View-specific functionality, things just get easier.

There is another very good reason to separate what model your view works with, vs. what model your domain works with -- model binding.  There are some very real security implications to think about here, which will be the subject of a future post.  But in short I leave you with this:  "The Client is in the hands of The Enemy."  Remember that they can POST whatever they want to your MVC application, its your responsibility to validate the inputs carefully.

 

 

 

Feeling satisfaction with design?
Hi all! My first ever blog post. I have to admit I'm a bit nervous as I am no writer. I wanted to ask the question of personal satisfaction with design. And when do you feel it. I just finished presenting a web design for a client and the strangest thing happened. At least it was strange to me as i had not heard or felt this for a while. The client expressed their absolute joy and amazement at the work I had presented to them. It was nothing really creative or mind blowing from my perspective but hearing the happiness in his voice over the work i had done for him was truly an uplifting to my soul. For the first time in a while i felt really satisfied with the job i had done. Was it just the happiness in his voice? Was it knowing he truly was happy with the work and not just saying it to be polite? Or was it that I was finally able to produce something worthwhile (I hope to god not as this is my career). Don't get me wrong. There are many levels of satisfaction of a job well done but sometimes you feel overwhelming satisfaction. So my questions to you are... When are you satisfied with your work? and Where does you satisfaction come from?
Announcing Isolator for Sharepoint
Typemock are offering their new product for unit testing SharePoint called Isolator For SharePoint, for a special introduction price. it is the only tool that allows you to unit test SharePoint without a SharePoint server. To learn more click here.

The first 50 bloggers who blog this text in their blog and tell us about it, will get a Full Isolator license, Free. for rules and info click here.

Rapid Tools for SharePoint
In case you haven't seen it, there is a packaged set of tools for working with SharePoint on Google code: http://code.google.com/p/rapid-tools/
 
There are a few nice tweeks to the setup and deployment of a SharePoint solution but this might not be for you if you already have a process in place.  That is, it seems to be a compilation of free tools already available.
 
In our case, we use Nant and Nantcontrib to automate our builds per the target environment.  This allows us to have different build/deployment configurations to choose from.  The configuration chosen depends on whether we're deploying to the development, staging, or production farm.
 
In addition, we use PsExec, part of the PsTools Suite, to execute the stsadm.exe commands on the target server.
 
Forms Authentication
I'm sure many of you are wondering why the infrequent posts on this blog.  It's all for a good reason: I've been working on a set of forms authentication Features.  Because, what's the point of a blog if we can't get feedback, right?  Of course this has all had to take a back seat to other projects in the works here, at the Fin.
 
I didn't do it all on my own, I had a great start by modifying a project on CodePlex created by Stacy Draper, the Forms Based Authentication Tools and Utils for SharePoint.  Not only was it a good, clean start but presents a good example of how to design SharePoint-styled forms that exist in the /_layouts directory.
 
The plan was to move a lot of the exisiting, inline code into class files, create forms for users to create their own account, and lock down the admin forms a bit.  I know, I know: I don't have to put code in an assembly for SharePoint.  Call me crazy - I just feel so naked leaving it visible to others.
 
The real problem is when I try to use a custom class for serializing user info to Xml.  It seems that .NET doesn't like the way I'm either A) Setting up my Web.config file B) serializing class containing user data or C) SharePoint just hates me.
 
In the Web.config file, I've added the inherits attribute to the <profile /> node and set the value to the fully qualified class name of my user data class.
 
I've tried a few different ways of indicating how SharePoint should handle serializing the attributes in the class but, so far, my efforts are to no avail.
 
I'll keep everyone posted and throw the finished solution up here when it's ready.

 ‭(Hidden)‬ Admin Links

Blackfin