![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Thread-Topic: returning business rule validation via method out parameter thread-index: AcYALicGbwUtQHeUQTeBvIASPtrtFQ== X-WBNR-Posting-Host: 64.160.115.139 From: "=?Utf-8?B?Um9iaW4=?=" <robinne123 (AT) newsgroups (DOT) nospam Subject: returning business rule validation via method out parameter Date: Tue, 13 Dec 2005 13:42:45 -0800 Lines: 22 Message-ID: <9FEF50A0-6EAB-43EB-BC90-4DB47D43A39D (AT) microsoft (DOT) com MIME-Version: 1.0 Content-Type: text/plain; charset="Utf-8" Content-Transfer-Encoding: 7bit X-Newsreader: Microsoft CDO for Windows 2000 Content-Class: urn:content-classes:message Importance: normal Priority: normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0 Newsgroups: microsoft.public.dotnet.framework.performance NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250 Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGXA03.phx.gbl Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.framework.performance:1109 6 X-Tomcat-NG: microsoft.public.dotnet.framework.performance Hi, I have a method that returns a dataset to the client. There will be times when the method should not return a dataset because it would violate a business rule. The issue I have is that I need to return the type of business rule violation to the client. I can throw a business rule exception (create a custom business rule exception) which would include a message that the client can catch and display. However, I am under the impression that exceptions are "expensive" (extra processing) and that they should be reserved for truly exceptional cases, which a business rule violation is not. the only other thing I could think of is to also have an out parameter that could represent the business rule violation (as a string, numeric code, collection or whatever). That way, the client can check to parameter to see if it has a business rule violation, and if it does, it could get the business rule violation error from the parameter (by reading directly or looking up a code). I have not seen this solution written up anywhere and would like some feedback as to whether this would be good practice. As for the dataset, I could just return null which hopefully the client would not attempt to use anyway if there were business rule errors. Thanks. |
#3
| |||
| |||
|
|
Hi, I have a method that returns a dataset to the client. There will be times when the method should not return a dataset because it would violate a business rule. The issue I have is that I need to return the type of business rule violation to the client. I can throw a business rule exception (create a custom business rule exception) which would include a message that the client can catch and display. However, I am under the impression that exceptions are "expensive" (extra processing) and that they should be reserved for truly exceptional cases, which a business rule violation is not. the only other thing I could think of is to also have an out parameter that could represent the business rule violation (as a string, numeric code, collection or whatever). That way, the client can check to parameter to see if it has a business rule violation, and if it does, it could get the business rule violation error from the parameter (by reading directly or looking up a code). I have not seen this solution written up anywhere and would like some feedback as to whether this would be good practice. As for the dataset, I could just return null which hopefully the client would not attempt to use anyway if there were business rule errors. Thanks. |
#4
| |||
| |||
|
|
Welcome to MSDN newsgroup. As for the returning business rule validation result from business components to client caller, I think you're right that using exceptions will be expensive in such scenario, and exceptions are mainly used for application code logic errors.... |
|
Also, as for using basic types, I'd prefer using integer value to indicate different processing result since it'll cause least performance overhead. And one example on this is just the COM component's HRESULT which is a 32 bit integer that contains the method processing result and error info..... Also, if you need to displaying some human readable error info at client caller side, you can consider maintaing a error message lookup table in memory to map the integer error code to string message.... |
#5
| |||
| |||
|
|
I have a method that returns a dataset to the client. There will be times when the method should not return a dataset because it would violate a business rule. The issue I have is that I need to return the type of business rule violation to the client. I can throw a business rule exception (create a custom business rule exception) which would include a message that the client can catch and display. However, I am under the impression that exceptions are "expensive" (extra processing) and that they should be reserved for truly exceptional cases, which a business rule violation is not. the only other thing I could think of is to also have an out parameter that could represent the business rule violation (as a string, numeric code, collection or whatever). That way, the client can check to parameter to see if it has a business rule violation, and if it does, it could get the business rule violation error from the parameter (by reading directly or looking up a code). I have not seen this solution written up anywhere and would like some feedback as to whether this would be good practice. As for the dataset, I could just return null which hopefully the client would not attempt to use anyway if there were business rule errors. |
#6
| |||
| |||
|
|
First of all exceptions are not as expensive as you might think. In the Win32 world I could have told you exceptions use almost no extra resource UNLESS an exception is thrown, and I'm almost certain this holds true for .NET too. Also in the case an exception is thrown, it's really not that expensive. There's a "yoda" page on the topic (no, I do not have the link - but you can dig it up). |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |