Question

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.

Était-ce utile?

La solution

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top