I've been reading into Model-View-Controller and was wondering where something like a XyzClient class would fit into this design. Splitting up MVC is easy when all you have are some views to display, some code to handle user interactions and some (maybe persistence driven) database entities.

But where does something like a PaypalClient or a DateFormatter class fit into? When talking of model I think of some database entity like Student or Course but not of some helper like PaypalClient. Is this a model or a controller? And where does something like DateFormatter (a helper for formatting dates) fit? Or should I prevent such classes when designing MVC (without them I would get massive controller code)?


In larger applications, you will benefit from further modularisation beyond MVC. The model can be broken down into:

  • Domain objects - like Student or Course that you mention
  • Data access objects (DAO) - code to load/save domain objects
  • Service layer - business logic that operates on domain objects

People often forget about the DAO layer because if you're using an ORM, it does all that internally. However, your PaypalClient is an example of an explicit DAO. If you want to do a nice job, make sure you separate the Paypal domain objects from the data access objects.

DateFormatter should be part of the view. Are you using templates for the view? Most template systems let you define custom filters, which convert an object to a string. There is also the MVVM pattern, but that's more important when you're doing complex processing for the view; for simple date formatting that is overkill.

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.