473,748 Members | 2,887 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

return codes

we are trying to standardize return codes across our .NET
applications (that are soon to be developed.) What is the
best practice for standardizing return codes? I know of
only the following option.

Creating a class library that will contain the return
codes (which will be static strings). Calling the return
codes from this library across different applications.

Please let me know if you have implemented return codes in
a better fashion in your applications. your feedback is
appreciated. Thanks.
Nov 15 '05 #1
3 2357
If you want standardization across all classes, you should consider
enums instead of static strings.

I've seen many .NET solutions which contain a project called "Common"
(or something similar), with, among other things, a .cs file just for
listing out all the enums the application uses.

Erik

"c# beginner" <an*******@disc ussions.microso ft.com> wrote in message
news:02******** *************** *****@phx.gbl.. .
we are trying to standardize return codes across our .NET
applications (that are soon to be developed.) What is the
best practice for standardizing return codes? I know of
only the following option.

Creating a class library that will contain the return
codes (which will be static strings). Calling the return
codes from this library across different applications.

Please let me know if you have implemented return codes in
a better fashion in your applications. your feedback is
appreciated. Thanks.

Nov 15 '05 #2
Hello

If your return codes indicate errors, it is better to use exceptions than
return an error code.

Otherwise, as another poster already wrote, enums are very good option for
return codes.

Best regards,
Sherif
"c# beginner" <an*******@disc ussions.microso ft.com> wrote in message
news:02******** *************** *****@phx.gbl.. .
we are trying to standardize return codes across our .NET
applications (that are soon to be developed.) What is the
best practice for standardizing return codes? I know of
only the following option.

Creating a class library that will contain the return
codes (which will be static strings). Calling the return
codes from this library across different applications.

Please let me know if you have implemented return codes in
a better fashion in your applications. your feedback is
appreciated. Thanks.

Nov 15 '05 #3
It is also possible to embed the enum in a user defined structure and
return the structure, which can contain useful information about the
return state.

http://www.geocities.com/jeff_louie/OOP/oop11.htm

Regards,
Jeff
Please let me know if you have implemented return codes in

a better fashion in your applications.<

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1902
by: Josh Mcfarlane | last post by:
I keep trying to get myself out of the return-code mindset, but it doesn't seem to work. They are suppose to get rid of if-then statements of return codes, but you still have to do an if statement once the code leaves your control (3rd party libraries, OS functions, etc) to throw an exception? Does anyone have any good suggestions on a book or website that deals with exception handling that could help turn this poor mind off of return...
16
3947
by: Fao, Sean | last post by:
As far as I can tell, the standard has defined three portable return codes from function main() (0, EXIT_SUCCESS, EXIT_FAILURE). Personally, on all platforms I have worked with, EXIT_SUCCESS is, "#define EXIT_SUCCESS 0" and EXIT_FAILURE is, "#define EXIT_FAILURE 1". I have, however, been told that a few platforms define the two in reverse (#define EXIT_SUCCESS 1 and #define EXIT_FAILURE 0). If this is true, I would expect that it would...
10
15918
by: Tony | last post by:
I am running an application called AcroComm.exe to poll time clocks here at our company. I have written a small C# app that will poll the clocks based on information found in a DB. My problem is that AcroComm will sometimes stop polling in the middle of the process and terminate. The programing manual for the app says that it sends a code to the operating system when it is done that tells what has happend like the following: 0 ...
1
2874
by: Alex P | last post by:
Hi, i would like to check for a given query (insert, update, delete) if there is a key or constraint violation which prevents the query from being executed. Is such a feature implemented in the perl or java drivers? If so, could anyone point to a list of available return codes? Thanks
3
1463
by: RdS | last post by:
Where do I find return codes for MS methods. For instance the filesystemobject methods. I need to know what methods return (error codes, etc. and what they mean). I have searched MSDN and of course find the method syntax documents but the return codes are not present. What a method returns should be documented in the syntax document. Any help would be appreciated. Thanks.
24
2195
by: Earl | last post by:
I have all of my data operations in a separate library, so I'm looking for what might be termed "best practices" on a return type from those classes. For example, let's say I send an update from the UI layer to a method in a library class that calls the stored procedure. Best to return a boolean indicating success/failure, return a string with the exception message, or just return the entire exception?
3
55684
by: asearle | last post by:
Hallo everyone, I have a perl script which can return error codes. I have done this with, for example, 'exit 11;', which would (I imagine) send the exit code 11 (instead of 0) back to the calling program. I would now like to check that my error codes are being returned correctly and so wanted to write a short script to test this. Here I considered using the following ... $checkexitcode = system ("perl myscript.pl"); but believe...
8
1718
by: sloan | last post by:
Does anyone have any good articles on Exception Handing in DotNet. As a "get rid of the API mode of knowing if something worked, we're not in VB6 land anymore Dorothy". I have a few people at work who keep writing code like below. public string UpdateEmployee {
4
2480
by: barcaroller | last post by:
I am trying to adopt a model for calling functions and checking their return values. I'm following Scott Meyer's recommendation of not over-using exceptions because of their potential overhead. Here's the approach I'm currently looking at. I throw exceptions only from constructors. Destructors, of course, do not throw exceptions. All other functions return a signed integer. The values are all stored in one large header file (as...
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9324
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9247
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8243
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.