One long class or many shorter classes?

后端 未结 6 1078
醉梦人生
醉梦人生 2021-02-19 03:01

In PHP, is there any performance impact on using one long class with a lot of functions in it? Or is it advisable to use many small classes and call them separately when needed?

6条回答
  •  余生分开走
    2021-02-19 03:51

    First, think about clean OOP design.

    Very long classes with a lot of methods and properties are very difficult to understand.

    A set of well-designed classes with meaningful class names, method names and variable names are very easy to understand especially when it comes to maintenance period.

提交回复
热议问题