Design Question

  • Thread starter Thread starter Guest
  • Start date Start date
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");
 
Back
Top