Generally speaking in a MVC framework we have the Controllers that do things like making sense of a request, preparing the parameters and starting an action in the business logic through some kind of "entry point".

The business logic is where the real application is described and it's usually defined in terms of services, "models" and plain classes.

My question is, what is in your opinion the correct way to build some "entry points" for the business logic? Creating some services or plain classes offering the methods? Implementing some static methods in the models?

  • 2
    Question seems too broad. It all depends on the need of the business and code. Maybe you'll need upfront validation for the request that your framework will provide. Maybe you'll need a service as a business middleman to make your request match the needs of the business. You might not even have business involved and only have low level logic going on (i.e CRUD). – Steve Chamaillard Sep 22 '16 at 12:53
  • Do you think so? I concur that there may be different cases requiring different architectures, but in some way a common pattern (like MVC itself) may be helpful when designing applications. In some way you, if you implement MVC without shortcuts, a best practice to "activate" the Model should exist. – heapOverflow Sep 22 '16 at 13:06
  • In general, questions about "correctness" are unanswerable. There is no "correct" way, though there are "better" ways. Whether a "better" way is actually better for you depends on your specific requirements, which you have not stated here. – Robert Harvey Sep 22 '16 at 17:56

Model-View-Controller is primarily a User-Interface paradigm. It doesn't have much to say about your business logic. Rather, MVC provides separation of concerns between your business logic and the user interface via Views, Controllers and (sometimes) ViewModels. All business logic concerns are deferred to the Model.

The Model can be architected any way you want. You said it yourself: "it's usually defined in terms of services, "models" and plain classes." If you want a more formal expression of your entry points, create an abstraction layer that has the services, models and plain classes on one side, and methods that embody business processes and transactions (e.g. TransferMoney) on the other side.

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.