is PHP method body too long is it necessary to split the package?

Source: Internet
Author: User
Ask Php method body too long is it necessary to split the package?
A method body is too long, it is necessary to split the internal several major functions of the encapsulation call?
The premise is that the encapsulated method will not be reused in the case

------Solution--------------------
The problem with too long is that the code is inconvenient to view
So I might be breaking into several feature module files include.

If these details are to be called elsewhere, it is necessary to split into other units.
This is my personal practice.
------Solution--------------------
A method to complete several functions? It's obviously about splitting.
function is functional, there are several functions should have a few function
At this point, there is no country-specific difference




------Solution--------------------
This can also be considered as not much of a matter of reuse. You divide a long function into several functions. It's easier to read, and it's easy for others to see. And if you want to change it, just focus on a certain area to modify it. And MVC is a truth.
------Solution--------------------
The package structure will be clearer. and add comments. Avoid late maintenance does not look dizzy.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.