现在的位置: 首页 > 综合 > 正文

关于分层体系结构的思考

2014年01月25日 ⁄ 综合 ⁄ 共 908字 ⁄ 字号 评论关闭

优点:
1.解耦。上一层只依赖于下一层,如果测试下一层没有问题,那么问题就只可能出现在本层了。便于发现和改正BUG。
2.简化复杂问题。就比如tcpip协议的四层模型或OSI七层模型,各层分工明确,将一个复杂问题简化了。

摘自Bjarne Stroustrup(c++创始人)的一个采访:

Again, I object to the "Joe Coder" moniker. At best, it is patronizing. Realistically we are all "Joe Coder" outside our little comfort zones. Modern software is far too complex for a single person to be more than a novice in most aspects. I'm "Joe Coder" most of the time, and so are you. Since we are all "Joe Coder" most of the time, let's retire that way of talking and start attacking the issue of complexity in all its varieties the best we can. "Divide and conquer" is the basic weapon; abstraction and layering are popular and effective variants.
3.便于系统维护/升级。各层间通过接口解耦,接口与实现分离,从而可以非常方便的替换掉实现,或者升级实现等。
4.逻辑复用。例如原来基于B/S开发的程序现在要改成C/S,那么只要业务层的接口没有改变,那么业务层和数据层都可以直接复用。在如,只要数据访问层接口不变,那么使用便可以有对不同数据库的实现。
5.便于团队开发。只要各层接口在开发前规定好,那么各层可以独立开发,进化或维护。
6.方便部署。将各层开发成组件,则可以独立部署。

缺点:
分层过多限制了客户对系统的理解能力。tcpip便将OSI七层简化为了4层。另外分层过多也增加了系统的理解难度,当然也看客户的接受能力。虽然增大了灵活性,但同时也限制了客户的理解和同客户的交流。

 

 


抱歉!评论已关闭.