Вопрос

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