• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

MVC where to put business logic?

 
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Everybody likes MVC. Still implementation details vary. As far as I understand responsibilities are following:

Model - provides data
Controller - UI navigation and control events handling
View - displays model data, observes model

Where to put pure business methods? Firstly who invokes them? I guess Controller calls them when event is received from View. On the other hand these methods must be exposed to Controller and not View. So do Controller and View operate on different Models? Or these business methods are outside of Model itself and don't fall into any of M V or C categories?

Thanks!

Vladas
 
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would say model.

In my personal experience model is much more than a data retrieval area. It has business logic and complex algorithms that may result in required data.

In some situations, model has about 80% of responsibility for business decision and the controller has about 20%.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The responsibility of the Model is to execute the business logic. Providing data to the other layers is just a side effect of that responsibility, of having to enable the View to present the results of the business processing.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The controller is allowed some logic, too, for things like navigation. Without a good definition of "business" logic I'm not sure what that means to you. Deciding what page to go to next might be "business" in some worlds.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Business logic is a very confusing word in the software development world.
In my personal opinion,business logic should be classified into the following categories:
1) data integrity---should be implemented at model level.
2) workflow logic, again workflow is another source of confusion. suppose you have more than one component in your model. you might need to coordinate those components from the model. This logic should be implemented in controller.

Hope it helps
 
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic