Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I have custom MVC framework in PHP and my controller file has about 5000 lines.

The question is, is it a big concept flaw?

It is structured code with kiss method and quite maintainable.

Are there any rules that specify how large the controller should be?

And offcourse could it have some bad influence on web performance?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

While there are no hard rules about the size of a controller, 5000 lines is clearly beyond any reasonable size for a hand-coded class. Chances are this class is violating the Single Responsibility Principle (SRP) and therefore is flawed. You most likely have several methods in there that can logically be grouped together. See if you can't extract methods off into separate controllers: you are very likely to end up with a larger number of controllers with fewer lines of code per controller and well-defined responsibilities. Or package up code into separate classes that your controller can call into.

I can't see where performance would be a problem, and I doubt performance of your code would be anything but the last reason you would want to split up a 5000 line class...

share|improve this answer
    
you're right i try to split the file into smaller controllers grouped by same functions. –  JTC Jul 31 at 10:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.