C # Creating an error checking class?

I am very new to OOP, and in the program I'm working on, I have a Utilities class that contains some common methods. Should I include my error checking in the Utility class or should I create a new class only for error checking?

+3
source share
7 answers

Utilities Utilities usually have the unpleasant habit of becoming monsters - keep the error checking code separate.

+2
source

, , , Utilities. - , ().

, , OOP . , . "".

+1

, , , (.. ). , .

public static class Utility
{
    public static string GetSomeString(string someOtherString)
    {
        try 
        {
            // something
        }
        catch (exception ex) 
        {
            // handle error
        }
        return result;
    }
}
+1

. , , , .

, , Log4Net, AOP, , PostSharp.

0

, , , , . , , . internal.

0

Application_Error Global.asax? , .

0

id jsut ... , , EG , , ... ints ... end , . , ...

.

.

debug.assert - .

, . , .

iinstance WCF . IErrorHandler iirc , , , -, , , . , - , . , , . - ... , , , , .

- .

, . WCF, , , , ( ).

, , , .

, ... , , .

This view goes beyond OOP to more architectural issues — you need to know why you want to move the code to the utility class, and then you need to decide if you just need to put it ... I would suggest pulling it out well, but you should go further and think of error management as your own decision. His begging to solve the SOA style (or at least the project) imo .... its one of those things that is not only common in applications, but also invariant ....

0
source

Source: https://habr.com/ru/post/1746002/


All Articles