Saturday, June 28, 2008 -
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)
I think you should create your own membership.
Time to update the way membership is done.
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.
excellent episode
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.
@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 :)
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.
@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 = :)
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.
Another vote on adding another level of abstraction to the membership service.
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.
Hi,
I'm voting to stay using ASP.NET membership. You are creating store, so stay focused on it...
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?
Rob, I really love the photos you pick to support your slides. Where do you get them?
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
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.
jc that's in the StructureMapControllerFactory in the /Controllers folder.
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?
@Paul: good question - I don't know but I'll try to find out.
Thanks Rob. This is one of my favorites. Keep up the great work.