dtrvzd1171 2012-09-29 12:58
浏览 33

重构ZF控制器文件? [关闭]

I have a controller that is (IMO) too long (over 1200 lines). The main problem is that I have a lot of actions in it. I can group this actions in 3 groups:

  1. calendar related actions

  2. events related actions (let's call events a "submodule" of calendar)

  3. providers related actions (also a "submodule" of the calendar)

What would be the best way to reorganize the code.
Could I, somehow, split it in sub-classes? Or is there any ZF-specific way to achieve this goal without creating additional controllers for the calendar "submodules"?

  • 写回答

1条回答 默认 最新

  • donglv6960 2012-09-29 13:31
    关注

    There is no such thing as a best way.

    If you think your class is to big, you have to split the class based on separations of concerns principle.

    The Principle of Separation of Concerns states that system elements should have exclusivity and singularity of purpose. That is to say, no element should share in the responsibilities of another or encompass unrelated responsibilities.

    Separation of concerns is achieved by the establishment of boundaries. A boundary is any logical or physical constraint which delineates a given set of responsibilities.

    If your class does not violates the Separation of concerns principle, leave it as it is.

    评论

报告相同问题?

悬赏问题

  • ¥15 CARSIM前车变道设置
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败