One long class or many shorter classes?

后端 未结 6 1098
醉梦人生
醉梦人生 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 04:07

    For the record, the size is not the important part to consider in a class. What's key to a class are the dependencies of the classes.

    For example, a class that depends in the database should be separates in a special class, such a Repository / Dao / Dal / Persistence class.

提交回复
热议问题