Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGuled A.
10,605 PointsCan someone explain what exactly 'business logic' means in a simple manner? [MVC]
I am still having trouble understanding some terms used in an MVC. I understand the structure of an MVC and how each of the three components work except for what the model is. Specifically the 'business logic' part that people speak of. Can someone correct me if I am mistaken:
Model : The data in a software project.
Controller : Manipulates the model and displays it on the view. The controller hosts the functions that manipulate the data into doing specific operations for your applications. For example, there is a controller for adding integers, and the model contains the integers.
View : What the user interacts with.
1 Answer
Christopher Davis
13,738 PointsSimply put, business logic is how your models relate and interact with each other. A program is built to help solve a problem for a business, whether that's an accounting system, ERP, inventory management, etc. All of that can be done without software. So when you translate those steps/interactions into the work flow of your program: that's the business logic.
You actually have Model code in your Controller example. The Controller is for directing a request to the proper Model(s), and then serving a response to the View(s). Here's a general work flow: a request is sent to your application to add two integers together. Your Controller knows to send that information to your Model, which performs the calculation and returns the sum. The Controller then takes that sum and sends it to the View where it will be displayed to the user.
A lot more can happen along the way (validation, logging, persistence, serialization, etc), but that's the simple gist of how it all goes together.
Guled A.
10,605 PointsGuled A.
10,605 PointsExact response I wanted. Thank you so much.