Search the web
Sign In
New User? Sign Up
altdotnet · Alt Dot.Net Discussions
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Show off your group to the world. Share a photo of your group with us.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Passing messages from the application layer to the View (asp.net mvc   Message List  
Reply | Forward Message #22424 of 23247 |
Re: Passing messages from the application layer to the View (asp.net mvc)

don't throw the exception. it is not good practice and it's expensive to raise
exceptions for what is essentially a validation concern.

Notification Pattern:
http://weblogs.asp.net/bsimser/archive/2007/06/04/extending-the-notification-pat\
tern-example.aspx


have a look at the nhibernate validator:
http://nhforge.org/blogs/nhibernate/archive/2009/04/02/nhibernate-validator-and-\
asp-net-mvc.aspx








Mon Jul 13, 2009 3:40 pm

chevronboyde
Offline Offline
Send Email Send Email

Forward
Message #22424 of 23247 |
Expand Messages Author Sort by Date

Let's say I have an AddProductToCartTask with a method Execute(). Now, the task is being called from a Controller. In the Execute method , there is a check...
siroco_x
Online Now Send Email
Jul 9, 2009
8:20 am

Can't you always use the same viewmodel type with an enumeration of message objects for what has happened / failed with the cart operation along with the model...
Ryan Roberts
ryan.roberts57
Offline Send Email
Jul 9, 2009
10:57 am

Can you return always the same objects to the view? When there is an error you will pass an error message and an empty "json object"...otherwise you will pass...
Domenico Musto
mimmomusto
Offline Send Email
Jul 9, 2009
11:16 am

Well, yeah, I could return an object with an empty or not error message. But the problem is with the AddProductTask that get's called by the Controller. Should...
siroco_x
Online Now Send Email
Jul 9, 2009
11:59 am

I use Udi's domain event pattern ( http://www.udidahan.com/2008/08/25/domain-events-take-2/) for this, which is functional but breaks encapsulation in my...
Ryan Roberts
ryan.roberts57
Offline Send Email
Jul 9, 2009
12:41 pm

I suggest your "You do not have enough bonus to buy this product" should be an exception that is thrown from the AddProductTask method. For example, in the...
Jarrett Vance
jarrett.vance
Offline Send Email
Jul 9, 2009
1:57 pm

Well, from what I've read up to this point, using Exceptions as a messaging mechanism is frowned upon - as exceptions should really for .. exceptional stuff ,...
siroco_x
Online Now Send Email
Jul 9, 2009
5:54 pm

This situation is precisely when you should use an exception. If there is a business reason for AddProductTask to fail, such as "not enough bonus", then that...
Jarrett Vance
jarrett.vance
Offline Send Email
Jul 9, 2009
7:26 pm

I don't have an internet link, but in my experience using custom exceptions for flow control in a validation situation is frowned on by some. It could be a...
Chris Morris
workmo
Offline Send Email
Jul 9, 2009
8:51 pm

This condition is not exceptional. It is available for the user to do. If they don't have enough to get the product and they try AND you allow the user to take...
Adam Dymitruk
adymitruk
Offline Send Email
Jul 9, 2009
9:09 pm

... Define "exceptional". If a procedure cannot be completed, then you need some way of notifying the caller about the failure. You could return a value to...
Adelle Hartley
adellehartley
Offline Send Email
Jul 13, 2009
8:27 am

... Well said....
Jarrett Vance
jarrett.vance
Offline Send Email
Jul 13, 2009
1:37 pm

... I disagree. I probably want to react to a user data validation problem differently than a system failure (e.g. security problem, resource problem). "Hey,...
Chris Morris
workmo
Offline Send Email
Jul 13, 2009
2:57 pm

Exceptions mean that the code has gotten into a state it should not be in so I'm going to spew out everything I know so someone can address the issue. For...
Michael D. Brown
mbrebrown
Offline Send Email
Jul 10, 2009
2:09 pm

... Yeah, I don't think exceptions are for "exceptional" situations anyway. I like the advice in Framework Design Guidelines, throw if the member cannot do...
Colin Jack
colin.jack
Offline Send Email
Jul 11, 2009
9:48 am

don't throw the exception. it is not good practice and it's expensive to raise exceptions for what is essentially a validation concern. Notification Pattern: ...
chevronboyde
Offline Send Email
Jul 13, 2009
3:41 pm

See the notification pattern. Cheers, Greg ... -- Les erreurs de grammaire et de syntaxe ont été incluses pour m'assurer de votre attention...
Greg Young
gumboismadeo...
Offline Send Email
Jul 10, 2009
2:16 pm

Yeah I agree, notification is a good option for many of these cases. 2009/7/10 Greg Young <gregoryyoung1@...> ... Yeah I agree, notification is a good...
Colin Jack
colin.jack
Offline Send Email
Jul 11, 2009
9:46 am

Well, I'm gonna go the event way : launch an event from the task, catch it in the controller, set the message in a global message repository thingy - that will...
siroco_x
Online Now Send Email
Jul 11, 2009
7:09 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help