문제

I have a huge php class with very long code in it. This make the file is big with lots of coding and hard to maintain. Is there anyway that I can split the class into a few files for easier maintaining?

Thank you.

도움이 되었습니까?

해결책

It depends on whether or not you can split the class in to subclasses.

What I mean is that you should ask yourself "does this method apply to this class or would it belong to a subclass?"

For example,

Class Animal
  - dog_bark()

dog_bark() could be moved to a class named Dog, and the method renamed to bark()

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top