Welcome Guest, Not a member yet? Register   Sign In
What is business logic?
#2

[eluser]charlie spider[/eluser]
There's no set laws about how you have to use MVC.

My personal understanding is that BOTH the controller AND the model are part of the business logic, the view is the presentation logic and the database is obviously the data. But for others the model is an integral part of the data level and the three levels of MVC translate directly to the three levels of a three tier application.

Models that are written specifically for one particular database table could be considered by some as part of that data level. I use my model for generic non-specific CRUD stuff but keep all of the details in the controller. So my models don't apply to any particular table or database so I don't consider them part of the data layer.

So for example, I have a function in my main model for returning a key->value array from a table, but it is in the controller that I dictate what column will be used for the keys, what column will be used for the values, what table the data is to be pulled from, and even whether the array is to be ordered and by which column to use for ordering. This keeps a lot of redundant code out of my controllers, but in no way are my controllers "skinny".

For more OOP type programming I would think that more logic would get pushed into the model, but maybe not. I tend to write more procedural stuff and my methods make sense for me. If you are working with a team, then you have to do what works best for the team.

Ultimately though, do what makes the most sense for you in your particular enviroment/situation. Maybe you will use a "fat" controller on one project and a "skinny" one on another project. Some people don't use models at all and have all of the non-presentation coding (the business logic) in the controller. Whatever floats your boat.

With regards to your example, I think you could simplify it greatly by only having one field to determine your dismiss/remind status.

Lets' call it "notification_reminder"

if "notification_reminder" is set to 0, or "0", or FALSE, or NULL, then there will be no reminder

if "notification_reminder" is set to 1, or "1", or TRUE then there will be a reminder

they are basically the two sides of the same single coin

your method duplicates the functionality (unless I am missing something else you are intending to do) and opens up the possibility of errors. You are using two coins, one for "heads" and one for "tails".

What if somehow, an update gets interupted, and you end up with both the "dismiss" AND the "remind_me_later" fields set to TRUE ??? What kind of comedy hijinks will that bring about?

Ummm.. the coin toss resulted in both "heads" and "tails"!?!?!?!


Messages In This Thread
What is business logic? - by El Forum - 04-29-2010, 10:11 AM
What is business logic? - by El Forum - 04-29-2010, 04:53 PM



Theme © iAndrew 2016 - Forum software by © MyBB