Home MVC Storefront

MVC Storefront, Part 15: Code Review With Ayende

Normally I would have gone through this many times already, however I have the good fortune of all your comments :). Even so, it's always a good idea to take a timeout and make sure you're not going off the deep end. In this episode I do a code review with Ayende and Steve Harman and have a really nice AHA! moment.

Sleep is for Saps
This episode took three tries. I had some great stuff with both Steve and Ayende and Camtasia crashed on me, and I lost it all. It turned out for the best, however, since it really made me think a lot and when editing the "redo" (which is what you're about to watch), I had a major AHA! moment that I think is golden. I love those moments!

Ayende (or Oren...) doesn't seem to need sleep. Both times we recorded, it was 4:00am in Israel (where he lives). I kept asking him if it was too late and he insisted that it was "just fine thank you".

At the end of the recording he told me he was watching the sunrise. Dude's a freak. And I can't thank him enough.

Leave Your Ego At The Door
The major thing when doing code reviews is to LISTEN and THINK. I disagreed with Oren on a few points (as you'll see), but as I thought it over, I realized the points he was making and found a nice way to solve the issue. THAT is absolutely golden.

I don't have to say this, really, but I feel compelled: learning is about the ego check. It's not easy - I'm proud of this thing and I'm really happy that Ayende is as gracious as he is. I learned a ton and I'm very glad for it.

You can watch it here (44 MB, 34 Minutes)

Chris Kolenko avatar
Chris Kolenko says:
Saturday, June 28, 2008

I think you should create your own membership.

Time to update the way membership is done.


Michael Aird avatar
Michael Aird says:
Saturday, June 28, 2008

Thanks for doing this, I've really been enjoying the series.

Now, what i'd love to see implemented next is an interface for "Catalog Management". This would demonstrate patterns for creating and updating complex objects when you're using linq in a "disconnected" way.


c.sokun avatar
c.sokun says:
Saturday, June 28, 2008

excellent episode


Justin avatar
Justin says:
Saturday, June 28, 2008

Thanks for another great screencast.

Assuming I have the latest code I found a bug in your UserService.Register method:

//see if the user is in the system already

User userCheck = GetUser(newUser.UserName);

if (userCheck != null)

throw new InvalidOperationException("This user already exists");

userCheck is never null since you are returning an anonymous "Guest" user if the user doesn't exist in the database.


Rob Conery avatar
Rob Conery says:
Saturday, June 28, 2008

@Justin - I haven't updated the source yet since I haven't done any major work. I will after the next episode and yah, i saw that silly bug :).

Thanks for the help :)


Scott Hardin avatar
Scott Hardin says:
Saturday, June 28, 2008

Great work Rob.

I'd lean toward eliminating the membership provider. How many developers looking at MVC, DI and separation of concerns are going to use your project to integrate with an existing membership provider compatible system? I'm guessing that number is small.

In a recent project, I modified the source code of the MSFT membership provider to allow the user identifier to be their e-mail address instead of a user name. Although the change was likely easier than rolling my own, it affected many stored procedures. Plus I'm stuck with the membership provider's POCOs, stored procedures and table definition that is not consistent with the architecture for the rest of the project.


Chad Myers avatar
Chad Myers says:
Saturday, June 28, 2008

@Rob: Great job again.

15 episodes... I think it's time for a bloopers episode :)

RE: Membership - Membership has a lot of great functionality in it, it's just that it's everything and the kitchen sink all in one big monstrosity that you can't plug into very easily. It's very opinionated which is fine, but opinionated + closed = :( opinionated + open/highly-pluggable = :)


Omid Zaman avatar
Omid Zaman says:
Saturday, June 28, 2008

Thanks Rob,

I am following your MVC Storefront series closely.

I was waiting for membership :).

Once I was looking to "SubSonic-powered ASP.NET MVC Forums" as an architectural pattern to use MVC and subsonic in my project but there was the same issue, two different database table for storing user data.

I think its better, you build your own membership based on your architecture.

In this way this tutorial will help newbie people like me to use MVC and based on your architectural pattern.

as a framework to build another application.

Great series by the way, can't wait for more.


Firefly avatar
Firefly says:
Saturday, June 28, 2008

Another vote on adding another level of abstraction to the membership service.


Chris Kolenko avatar
Chris Kolenko says:
Sunday, June 29, 2008

Hey,

Is this "future query" stuff a made up terminology from Rob?? I can't seem to find anyones thoughts on the matter.

I'm sort of stuck with a similar problem with a project of mine and having this awesome power would be great.


Petr Snobelt avatar
Petr Snobelt says:
Monday, June 30, 2008

Hi,

I'm voting to stay using ASP.NET membership. You are creating store, so stay focused on it...


Meisinger avatar
Meisinger says:
Monday, June 30, 2008

I think it would have been great if you would have told Oren that you were thinking about moving towards Entity Framework. It would have lend itself to some great audio...

On a serious note... have you thought about using or writing custom classes that implement IPrinciple and IIdentity?


hj avatar
hj says:
Tuesday, July 01, 2008

Rob, I really love the photos you pick to support your slides. Where do you get them?


Remmus avatar
Remmus says:
Tuesday, July 01, 2008

Hello Rob,

You've probably seen this already but if you are looking at solving you lazy loading problems this works

odetocode.com/.../12122.aspx


jc avatar
jc says:
Wednesday, July 02, 2008

Maybe I'm missing it, but where are the conrollers registered with StructureMap? I can't get the code to run and it seems to be because the controllers aren't being registered.


Rob Conery avatar
Rob Conery says:
Wednesday, July 02, 2008

jc that's in the StructureMapControllerFactory in the /Controllers folder.


Paul Linton avatar
Paul Linton says:
Wednesday, July 02, 2008

Hi Rob,

Thanks for all the great work and advice.

I have changed my code to reflect the changes you have made to lifetimes of db/repositories. My app then broke on the db.ObjectTrackingEnabled = false; statement ("Data context options cannot be modified after results have been returned from a query"). From memory, you originally added this as a performance tweak but now it seems to have disappeared from your code base.

Is there a neat way to set ObjectTrackingEnabled = false when the dataContext is being used by a repository? I suppose I could have if(db.ObjectTrackingEnabled) db.ObjectTrackingEnabled = false; in the repository constructor, what do you think?


Rob Conery avatar
Rob Conery says:
Wednesday, July 02, 2008

@Paul: good question - I don't know but I'll try to find out.


Dane O'Connor avatar
Dane O'Connor says:
Monday, July 21, 2008

Thanks Rob. This is one of my favorites. Keep up the great work.



Search Me
Index Of MVC Screencasts

You can watch all of the MVC Screencasts up at ASP.NET, and even leave comments if you like.

Subscribe

Popular Posts
 
My Tweets
  • Isn't the Rails/Asshole thing dead? http://tinyurl.com/57dmvx
  • Pushups last night: 17, 13, 9, 7, 3
  • @kevindente my wife (and me) consider the Roomba to be on par with Tivo in terms of generation-defining technology
  • @kevindente I'll hold you and we can cry together. Maybe you can ... even ... blog about it.
  • Writing tests for InventoryService - talk about a slipper-slope process! Is there such a thing as Cart Concurrency? I dunno! Maybe?
  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).