Design Question

G

Guest

Ladies and Gentlemen,

I have 2 design questions for ya'll. And this pertains to developing an
ASP.NET application.

Question #1
Which is the correct way (and why) for designing class methods?

1. Use reference (input/output) parameters to return multiple pieces of
information to the caller
(please ignore naming conventions, for example only)
public void MyFunc(int Param1, string Param2, ref int OutParam1, ref string
OutParam2)
{
// do stuff
OutParam1 = something;
OutParam2 = somethingelse;
}

2. Pass back a object
public MyClass MyFunc(int Param1, string Param2)
{
return new MyClass(something, somethingelse);
}


Question #2
Which is the correct way (and why) for handling error conditions?

1. Pass back an integer value indicating success or failure (like in the
Win32api)

2. Raise an exception
throw new ApplicationException("my error condition");
 
H

Hector Minaya [VB.Net MVP]

Both are correct,

depends on the application you are working on.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top