Application logic inside class or inside model? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Application logic inside class or inside model? (/showthread.php?tid=38109) |
Application logic inside class or inside model? - El Forum - 01-30-2011 [eluser]andyy[/eluser] If one was writing an application that has all the functions broken down into class methods and you need to run some logic: if, else, etc - should you have the methods returning bool values and create the logic inside of the model, or should you have the class/method run the logic returning the result? It's hard to explain, hopefully that makes sense. Maybe an example to help: How I was thinking it should work.. Code: /** But I've also thought about this.. Code: /** I've been thinking that any method's result should be determined within the model. If there is anything more than a bool value that needs to be returned, use an array and use the arrays values within the model. Thoughts? Application logic inside class or inside model? - El Forum - 01-30-2011 [eluser]bscott[/eluser] Or you could have getStatus and getErrorMessage methods in your Payment class and use Code: $z->chargeCard(); This way the determination of sucsess/failure and the content of the error is encapsulated in the Payment class and the action taken dependant on the result of the chargeCard method is in the model. |