Welcome Guest, Not a member yet? Register   Sign In
Is it okay/advisable to use input methods directly in models?
#5

[eluser]Watermark Studios[/eluser]
Encapsulation 101 - The model should only be self-aware. It should not depend on exterior environmental factors. What happens if you want to use the same model to handle a user insert from a file upload? Or from a Facebook plugin? I'm working on an application right now that integrates with PayPal's PayFlow Pro Gateway with recurring billing. I am using the same User model for admin control of accounts as I am with my PayPal integration controller.

Best practice is to keep $_POST out of the model. Let the model be as generic as you can make it and let the business logic handle the $_POST-to-property assignment. It's the same effort up front to do so, but it makes the User model more portable. I re-use my User model in almost every application. I make changes here and there, but because of encapsulation, I don't have to think about how my application needs to be molded around my model.

Best of luck!

Ken


Messages In This Thread
Is it okay/advisable to use input methods directly in models? - by El Forum - 10-19-2010, 04:25 PM



Theme © iAndrew 2016 - Forum software by © MyBB