Home MVC Storefront

MVC Storefront, Part 7: Helpers and Routing

In this installment, I continue working on the UI as I ready the demo for the client. I also talk at length with Scott Hanselman about Routing and ways you can test your Routes with Phil Haack's cool Route Debugger.

UPDATE: If you download the code for part 8 (changeset 4985) you'll need to be sure you have the 0416 Source Release for MVC installed.

Previously, On The MVC Storefront

  • Part 1: Architectural Discussion and Overview. I cover the initial architecture here, in part 1, where I discuss the Repository Pattern with Ayende Rahien and Steve Harman. I also ask Phil Haack what's first: The Test Chicken or the Model Egg.
  • Part 2: The Repository Pattern. I walk through our Repository implementation and write out the first main set of unit tests. I also  structure up the initial service layer methods and interfaces.
  • Part 3: Pipes and Filters: I discuss the feedback from Parts 1 and 2, and then dive into the Pipes and Filters implementation on the IQueryable repository.
  • Part 4: Linq To Sql Spike. I create a "spike" - a bit of functionality to test a thought or inspiration - to make sure that Linq To Sql will work for my data access pattern.
  • Part 5: Globalization. I work with Damien Guard to refactor the database to deal with test data and globalization issues.
  • Part 6: Finishing The Repository, and Initial UI Work. I talk with Jon Galloway about CSS strategies and begin working in the Front end of the application

 

The Code as always is downloadable from here

Getting Longer Every Time
My goal has been to keep these down to 10-15 minute webcasts, but there's just way too much to show, and I feel like I don't want to pass up any details. This one clocks in at 27 minutes, but in there is a great discussion with Scott Hanselman on setting up Routes.

The next installment is coming up very shortly. Not much else to say...

Download Part 7 Here (40M, 27 minutes)

Technorati Tags:
Simon avatar
Simon says:
Thursday, May 01, 2008

"Getting Longer Every Time" I think that was the subject of a spam i got recently.

Keep up the good work.


Gokhan Demir avatar
Gokhan Demir says:
Friday, May 02, 2008

Rob,

project file for the Commerce.MVC.Web is missing in the source code.


Stephen avatar
Stephen says:
Friday, May 02, 2008

I'm interested as to the choice of starting the site before the application model is complete..

To me, I'll have my entire app model built, mocked tested yadda yadda, before I touch the web applications that interact with it.. my next stage is usually to mock the the data (no css or anything) to check that navigation and data from the app model gives me everything I needed..

Once the site works as an unstyled dumb structure, I'll add in CSS and any JavaScript to designed to enhance the experience.


Jamie avatar
Jamie says:
Friday, May 02, 2008

@Stephen - That works if you have a client that's content to wait until it's entirely finished to see anything, but many clients want to see iterations throughout the development process and they want them to be pretty. They're usually "marketing types" that wouldn't know an app model from their butt and could care less what goes on behind the scenes as long as the front end looks pretty and appears to work.


Stephen avatar
Stephen says:
Friday, May 02, 2008

Mm, fair enough - usually we don't have a problem with explaining our process and basically why this is so, and why it keeps our 'throughput' high, and thus a; a final result faster..

But I see your point.


Francois Tanguay avatar
Francois Tanguay says:
Friday, May 02, 2008

@Stephen:

Having ALL the model completed upfront is anything but agile.

You'll need client feedback in order to know if you got it right and the best client feedback is by using your application; otherwise, it's pure speculation.

Although I agree that once you know a business domain well enough, you can guess acurately most of the time.


Craig Quillen avatar
Craig Quillen says:
Friday, May 02, 2008

How would you do a route to handle a category heirarchy that doesn't have a fixed depth?

Also if you don't have a fixed depth, then the product isn't always going to be in the same slot in the URL. Right now it's forced to always be in the 3rd position.

Hopefully routes support something a bit better than just passing the whole url to the controller for it to figure out.


Rob Conery avatar
Rob Conery says:
Friday, May 02, 2008

@Gokhan: You need to build the project - this dll normally isn't stored as part of source control.

@Stephen: As the others have pointed, I'm trying to be Agile with this.

@Craig: Routes are really flexible - you can come up with, literally, just about anything you want. This is just my choice as I think it reads well.


Stephen avatar
Stephen says:
Friday, May 02, 2008

Gah I'm gonna explode if I hear another person say agile, tdd, ddd, or any other development 'fad' there is right now! ;)

Francois, I do agree that developing an application without the client sounds like their input isn't included..

But in our experience, we've found that including the client directly into the development would often drag out projects to unbelievable timescales as we wait for clients to initiate testing.. not to mension clients constantly changing their minds anyway.. the point is that a client rarely does know what they really should have, as a studio offering a solution to a client- its up to you to guide them to understanding their problem and how and why it could be solved..

Many many studios will just blindly start work and then work through manipulating the code back and forth to get what the clients flavour for today is..

In our development, we have a requirements driving stage at the initial starting of a project, here we discuss what the solution will become, and break down (if nec) the solution into deployment milestones..

We (ourselves and the client) have to completely be happy with the proposed solution before anyone does a thing... minor concept mocking of static sites is sometimes there.

Personally I think our business would suffer greatly from us moving away from this model.. our timelines would become unmanagable and compromises would need to occur.. our client would probably walk away with something close to what they thought they needed, and crucially wouldn't be utterly pleased with the solution we provided them..


Rob Conery avatar
Rob Conery says:
Friday, May 02, 2008

@Stephen: I think everyone's familiar with the "way it' been done" - especially myself. Agile (sorry, said it again) really does work nicely - and there are various flavors of it.

I started using a light version of it 2-3 years ago, involving the client very early and very often in a strong "feedback loop". The closer they are, the more they see what you're doing and why.

>>>including the client directly into the development would often drag out projects to unbelievable timescales<<<

I think you misunderstand what Agile's about. Perhaps this can be a weekend project: head to Borders and pickup a book about it; see what you think. You'll hear many stories as to why everything you've asserted here is a problem with BDUF/classic models. Agile tries to do away with that.


Jesse Naiman avatar
Jesse Naiman says:
Friday, May 02, 2008

In light of the previous comments and due to my own desire to understand this process better could you recommend any agile books?

Keep up the great work this project is a fantastic idea.


Marco von Frieling avatar
Marco von Frieling says:
Friday, May 02, 2008

Hi Rob!

First at all, good work with the first 6 sessions. At the moment I'm waiting for session 7 to complete downloading and am very confused about the download speed of less than 50 KB/sec. Doess your server have a very high load level or is it so slow? I have a fast internet connection and normally about 400 - 500 KB/sec or even more.

As Craig asked about routes for hierarchically categories/data, I'd like to see how to query such data uising LINQ, or in general, how to write efficient recursive queries? (SQL Server 2005 provided Common Table Expressions for it, aree the supported in any way using LINQ to SQL?)

And secondly, are there any helper methods for

- absolute urls/action links (for beeing able to specify the protocol (e. g. http, https, ftp ...) or the host, port etc. parts of the url? These are useful for confirmation links etc. in emails, RSS feeds...

- action links allowing rich content in the link tag (<a {attributes generated by helper method here}>{rich content here}</a>). I guess sth. like this is widely used:

<a href="link-target-url"><img src="image-src-file-url" /></a>

There are two approaches to get this working, both require a bool parameter on the action link helper method:

1. option to not call any HTML encode routines on the content string

2. option to skip the closing a tag, just render the opening tag and optionally provided content and let the developer close the a tag in any way he wants. With this you are enable to concat the output of an action link helper call with the output of an image tag helper call and any other content or markup string.


Stephen avatar
Stephen says:
Friday, May 02, 2008

No Rob I DO get it, thats the problem.. feedback from our clients wouldn't be snap.. it would be.. 2 weeks of not looking at it.. then saying yea its fine.. then coming back 2 weeks later and saying.. actually could we do this?

While those 2 gaps aren't us working on their application nec~, it does make it hugely impossible to plan work around undetermined timelines..

I don't need a book to tell me what what a feedback loop is.. only that feedback loops in the past have ALWAYS meant weeks of waiting..


Rob Conery avatar
Rob Conery says:
Friday, May 02, 2008

@Jesse - There are so many and I don't have a preference - I'd say skim them and see which one works for you :).

@Marco: Middle of the day and things do slow down :). I have a nice fat pipe at MaximumASP, but I'm testing just how much they're throughput can handle :).

There are lots of ways to recursively structure a LINQ route. In one of the future webcasts I'll show that.

RE Helpers... Episode 8 is due in about 2 hours :)


Roger avatar
Roger says:
Friday, May 02, 2008

Rob,

I really appreciate you exposing your development process to us. It's nice to see how you are approaching this project, but what I like even more is when you work through problems with your code. This latest webcast has been the most informative for me thus far. The more time you spend on actually coding and then resolving the inevitable issues as they appear, the better for me. Obviously you have to cater to the larger audience, but I'm new to MVC and this series is proving to be a great intro for me.

Thanks


Mike avatar
Mike says:
Friday, May 02, 2008

One of the best screencast series I have ever seen and the best you have ever done.

Keep up the great work!


Vijay Santhanam avatar
Vijay Santhanam says:
Saturday, May 03, 2008

Nice rob. I'm going to copy your helpers for pathing css/images.

Ha! You make the assumption that IE7 and FF are the only two browsers. What about IE6?! So many of my clients' visitors still use ie6. I wish I could tell them to upgrade, but that's never going to happen.


hj avatar
hj says:
Saturday, May 03, 2008

Excellent work!

But testing if the routing works by "Setting a breakpoint and inspecting the variables" seems not to be consistent with your overall TDD approach.


max avatar
max says:
Monday, May 05, 2008

Isn't it a bit much to create a helper to do your paths when you could simply use say "/Content/Css/Site.css" or "/Content/Images/logo.png"? I hear you mention keeing things simple alot and this seems to go against that. How often does your sites images, css, js paths really change anyway?


Rob Conery avatar
Rob Conery says:
Monday, May 05, 2008

@max

>>>How often does your sites images, css, js paths really change anyway?<<<

Once is enough :).


David Alpert avatar
David Alpert says:
Monday, May 05, 2008

i echo hj's comments above; i was disappointed to see you and Scott write your route, throw in a breakpoint, and fire up a debugger/ie instance to test your route.

For the purpose of demonstrating that url pieces get auto-mapped to ControllerAction methods (like /store/scott/rob) it was useful to use that breakpoint; that's one of MVC's magic conventions and nice to see it shown off visually.

Nonetheless, i kept waiting/hoping that you'd build some RouteTests to verify that the routes get resolved to the correct controllers and index methods, testing after the fact if not before. I think MVCContrib has some helper methods that make that easy...

Lest this be heard as heartless criticism, however, let me say that i am enjoying this series much, Rob, and want to thank you again for exposing your process to the world.


Rob Conery avatar
Rob Conery says:
Monday, May 05, 2008

@David - thanks :). At this point you have to Mock up some things to test the routing and we sort of "sidestepped" it to stay on target - but you and HJ are correct - we should be testing these first.



Search Me
Subscribe

Popular Posts
 
My Tweets
  • @codinghorror: I may be weird but I don't ask my cats to write my blog entries :p.
  • @blowdart sure! Wanna come on and do a webcast with me - plugging CardSpace in?
  • People are very, very weird. Skypecasts are creepy.
  • Is Rob Howard trying to tell us something? http://www.rob-howard.net/
  • New storefront posted- all about OpenID :) http://tinyurl.com/5rkgux
  About Me



Hi! My name is Rob Conery and I work at Microsoft on the ASP.NET team. I am the Creator of SubSonic and was the Chief Architect of the Commerce Starter Kit (a free, Open Source eCommerce platform for .NET)

I live in Kauai, HI with my family, and when my clients aren't looking, I sometimes write things on my blog (giving away secrets of incalculable value).