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 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思