dongzhengzhong1282 2012-06-14 14:59
浏览 21
已采纳

PHP - 前端控制器模式。 一个巨大的转换声明

I'm using the front controller pattern in conjunction with a command resolver class, whose only function is to map requests from the view to a command object.

Everything works fine, but I'm starting to wonder if my implementation, which basically consists of a switch statement, is actually bad practice.

Would it be better practice to replace this switch statement with an XML file, or to map the requests physically to files in the command class (i.e. the request name would be the file name), or is a switch statement fine for this purpose?

Edit: I am using MVC, the front controller exists in the controller. This is more of a design pattern within a design pattern question.

  • 写回答

2条回答 默认 最新

  • dongyong1897 2012-06-14 15:02
    关注

    By using switch, you are hardcoding a lot. How about writting command function which will check possible array of files (possibly from cache which will be filled once by reading directory with files), and load a file if its ok.?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?