Lead Product Evangelist @Kentico, Founding partner @craftbrewingbiz. love to learn / teach web dev & software engineering, collecting vinyl records, mowing my lawn, craft 🍺
Often what I'll do is either use a private method inside the facade for standard error handling / logging if there's a lot of overlap or use a static class in C# with extension method support so, the class might look like this for logging:
publicstaticErrorExtensions{publicvoidLogError(thisExceptionex){// Do some actual error logging hereConsole.WriteLine(ex.Message);}}
If, for some reason, you have multiple facades in an application (can happen if you support different types of external callers, for example), you can extract a base class for all facades and add protected methods for these cross-cutting concerns.
The other thing you could consider is following an Action pattern where you have a single method that does standard stuff like validation and error handling and it just takes in a function that it invokes for the implementation-specific logic.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
What are your thoughts on moving the error handling to a decorating class that wraps the facade? Something dedicated to error handling...
The same could be done for logging or caching to keep cross cutting out of the business logic.
Often what I'll do is either use a private method inside the facade for standard error handling / logging if there's a lot of overlap or use a static class in C# with extension method support so, the class might look like this for logging:
and then in my handler I might do:
If, for some reason, you have multiple facades in an application (can happen if you support different types of external callers, for example), you can extract a base class for all facades and add protected methods for these cross-cutting concerns.
The other thing you could consider is following an
Action
pattern where you have a single method that does standard stuff like validation and error handling and it just takes in a function that it invokes for the implementation-specific logic.