I’ve recently worked on a project where every method contained a return code. Example:
public Boolean LoadPageData(out int returnCode) { ... }
or
public String GetCustomerName(out int returnCode) { ... }
Is using return codes considered good practice, bad practice, or simply personal preference in the context of OOP programing (Specifically ASP.Net)? If they do have a place is including a return code on every method the correct usage?
Typically, the need for return codes in addition to the regular return value is a sign of poor design.
Return codes are used to signal success or various degrees of failure. In OOP, a method succeeds if the method returns at all. If there are any various degrees of failure, you should throw the appropriate exception.