I'm building an API in .net that wil capture webhooks events of a third party service.

Lots of actions on the third party service will trigger the webhooks.


My question is should I capture this all in 1 Controller. This will reduce the amount of code. but certainly will make it lot more complex. Checking wich object it is making a dynamic insert/update to the database & ...

Or should't I create for every object a different controller, so know which object I have to handle.


The information you gave is a little sparse but from a very "far away"-point of view I would recommend using multiple controllers. In modern software engineering you should, as a rule of thumb, tend to reduce complexity wherever possible. This helps to fulfill non-functional requirements like:

  • Testability - you can mock data for every controller and every webhook separately
  • Maintainability - adding, bug fixing, removing functionality becomes easier per controller
  • etc.

Try to generalize common tasks between controllers. Otherwise it is no shame to introduce some redundant code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.