0

I've inherited a project that is built in a PHP MVC framework (Zend in this case), and is using different modules for the mobile and desktop versions of the site. The project is in early stages (so functionality is only about 20% complete and buggy) and as you may have guessed there is alot of repeated code.

The desktop and mobile sites will have different layouts, although there are common elements. My instinct tells me separating these into different Zend modules is not the best approach. I'm thinking I should refactor the code into a single module, and confine the layout differences to views as much as possible. Also, leveraging responsive design as much as possible and only using separate views where necessary (as dictated by my client's requirements). Conceptually I see many advantages to this approach, but being rather new to Zend (and mobile design as well), I'm wondering if I am going to encounter any Zend-specific headaches if I do this refactor (just being a bit paranoid here)?

What is considered "best practice" in general (mobile & desktop co-design)? Any specific advice about Zend MVC?

4

1 回答 1

1

使用模块的原因是为了提供一种将模型分成具有不同关注点的区域的方法,例如用户部分/管理部分,您实际上有两个不同的模型。

使用模块来分隔移动版和桌面版绝对是错误的做法,您将到处都有重复的代码。如果您以后必须支持更多的移动格式怎么办?您最终可能会得到相同的代码重复 3 次、4 次或更多次。

您的直觉是正确的,移动设备或台式机的模型将保持不变。控制器应相应地决定向客户端提供哪个视图。

遇到这个问题将是一个很好的测试,你是否正确地分离了你的关注点。您应该最终得到一个系统,您可以轻松地将其他视图放入其中,并且根本不需要修改模型。

对于什么是大主题,这是一个相当简单的答案,但我希望它有所帮助。

于 2012-07-02T08:13:05.407 回答