2

I have a MVC application which uses events(hooks) and I have a question about when to trigger an event.

There are three options:

  • trigger in models(this approach will mess-up the code, but gain a little more flexibility)
  • trigger in controllers(after or before calling some models)
  • creating a new layer of abstraction between controllers and models that extends my models and trigger the event(decorator pattern)

Thank you

Sorin Vladu
  • 1,768
  • 3
  • 21
  • 37

1 Answers1

0

Third option - within your viewmodels or repository/unit of work implementations

Moho
  • 15,457
  • 1
  • 30
  • 31
  • Can you be more specify please? I don't understand what you mean with viewmodels or repository/unit of work... – Sorin Vladu Jan 24 '14 at 12:48
  • You have a lot of reading to do, then; read up on the repository and unit of work patterns. Also search for MVC with ViewModel. After reading about these patterns, you should have a much better idea of how you want to go about solving your problem – Moho Jan 24 '14 at 12:52