its very unlikely that all 1000 lines need to be in the controller
most of them can be outsourced to libs, components or even model
functions
only the remaining lines (maybe the half) should then be divided - and
only if it makes sense
you should add _ in front of the method, though. this way its not a
normal action but a controller specific submethod
function text() {
//doSomething
$this->_add();
$this->_addMore($params); // its possible to pass params
//doSomethingElse
}
function _add() {
//doSomethingDifferent
}
function _addMore($params) {
//doSomethingTotallyDifferent
}
this does usually make sense if several functions need the same
functionality (like passing some navigation to the view) and you dont
want to repeat yourself.
in your case it can make sense, too - that is if it really helps to
make the code more readable and testable.
On 14 Jul., 08:15, Master Ram <[email protected]> wrote:
> Hi. to all
>
> in my controller i am using one function.
>
> function text() {
>
> ;;;;;;; 1000 lines of code;;;;;;;;
> ;;;
>
> }
>
> function add() {
>
> //Here i want same code. is having in text function. it is possible to
> call text() here.
>
> // i want to reduce the code.
>
>
>
> }
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en