Pergunta

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.

Foi útil?

Solução

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()

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top