Skip to main content
replaced http://programmers.stackexchange.com/ with https://softwareengineering.stackexchange.com/
Source Link

It helps to make a distinction between:

  • Helpers - support code that is not aware of your model, e.g. date formatting.
  • Services - support code that is aware of your model, e.g. bills credit card, updates user record, sends user email

I'm not quite sure which of these you mean by "library". Anyway, following your terminology, I suggest this chain:

router > controller > services > models 

The service layer is optional: for simple operations the controller can call the model directly. And anything can call a helper.

To refine your terminology a bit more, you can modularise the modelmodularise the model.

It helps to make a distinction between:

  • Helpers - support code that is not aware of your model, e.g. date formatting.
  • Services - support code that is aware of your model, e.g. bills credit card, updates user record, sends user email

I'm not quite sure which of these you mean by "library". Anyway, following your terminology, I suggest this chain:

router > controller > services > models 

The service layer is optional: for simple operations the controller can call the model directly. And anything can call a helper.

To refine your terminology a bit more, you can modularise the model.

It helps to make a distinction between:

  • Helpers - support code that is not aware of your model, e.g. date formatting.
  • Services - support code that is aware of your model, e.g. bills credit card, updates user record, sends user email

I'm not quite sure which of these you mean by "library". Anyway, following your terminology, I suggest this chain:

router > controller > services > models 

The service layer is optional: for simple operations the controller can call the model directly. And anything can call a helper.

To refine your terminology a bit more, you can modularise the model.

Source Link
paj28
  • 1.7k
  • 1
  • 13
  • 15

It helps to make a distinction between:

  • Helpers - support code that is not aware of your model, e.g. date formatting.
  • Services - support code that is aware of your model, e.g. bills credit card, updates user record, sends user email

I'm not quite sure which of these you mean by "library". Anyway, following your terminology, I suggest this chain:

router > controller > services > models 

The service layer is optional: for simple operations the controller can call the model directly. And anything can call a helper.

To refine your terminology a bit more, you can modularise the model.