Halo again, I checked out private methods and tried putting the codes into 2 private methods, calling them from the main controller function. Unlike what I feared, the variables declared in the private method are available in the main controller as well and that saves a lot of time (the code looks better now although I'll need more time to reorganize everything)
Brett: Yes I heard of the concept before and make research about it. Putting the codes in model and calling them from the controller isn't ideal right now. I'm continuing someone else work and if I do this, it will be different from the rest of the application. Nevertheless, I will adopt this practice in my future application. For other people (newbies like me) who have the same problem, let me recap this: You have hundreds of lines of code in a single function and they're messy. You wanted to reorganize without spending too much time reworking them and without breaking a huge application. Solution: break the codes into several function and call the subfunction from the main function. (Calling private method from the public method) in the controller. If you can, put the code in the model instead of controller and call it from the controller instead: Controller code: $this->Model->whateverFunctionName(whatever variable needed); References: http://gluei.com/blog/view/cakephp-best-practices-fat-models-and-skinny-controllers https://trac.cakephp.org/wiki/Developement/CodingStandards Guys, that's for helping me out. Appreciate it a lot. P/S: Nudge me if there's something I could improve or do wrongly. I learn from my mistakes :) Cheers On 7 May, 08:56, tienzyee <tienz...@gmail.com> wrote: > Hi Brian, brett and yodi. > > Thanks for replying and pointing me out. That helps a lot. I'll try > that and google all that. I'll tell you the progress later. > Thank you again. > > On 7 May, 05:25, Brett Wilton <bdwil...@gmail.com> wrote: > > > You could use private functions in the controller or if the code lends > > to it make your models fat. > > > Just google something like "cakephp fat models skinny controllers" > > > Hope that helps. > > > ----http://wiltonsoftware.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---