Spring的设计哲学和个人见解

Design Philosophy

When you learn about a framework, it’s important to know not only what it does but what principles it follows. Here are the guiding principles of the Spring Framework:

当你学习框架的时候,不仅知道它是怎么运作的,而且知道它伴随这什么样的原理,这是非常重要的。这里有Spring框架的指导原理:

  • Provide choice at every level. Spring lets you defer design decisions as late as possible. For example, you can switch persistence providers through configuration without changing your code. The same is true for many other infrastructure concerns and integration with third-party APIs.在每个层次提供选择。Spring允许您尽可能延迟设计决策。例如,在不改变你的代码的情况下,通过配置来切换持久化提供程序。对于其他许多的下层基础考虑和第三方api集成同样是成立的。

  • Accommodate diverse perspectives. Spring embraces flexibility and is not opinionated about how things should be done. It supports a wide range of application needs with different perspectives.容纳不同的观点。Spring拥抱灵活性并且对于事情应该如何处理并不会固执己见。它支持各种不同角度的应用程序需求。

  • Maintain strong backward compatibility. Spring’s evolution has been carefully managed to force few breaking changes between versions. Spring supports a carefully chosen range of JDK versions and third-party libraries to facilitate maintenance of applications and libraries that depend on Spring.维护强有力的向后兼容。Spring的发展经过精心的管理,几乎没有在版本之间进行破坏性的更改。Spring支持精心选择的JDK版本和第三方库,以促进依赖于Spring的应用程序和库的维护。

  • Care about API design. The Spring team puts a lot of thought and time into making APIs that are intuitive and that hold up across many versions and many years.关心API设计。Spring团推花费了大量的心思和时间在API设计上,这些API是直观的,并且很多经得住版本迭代和岁月推移。

  • Set high standards for code quality. The Spring Framework puts a strong emphasis on meaningful, current, and accurate javadoc. It is one of very few projects that can claim clean code structure with no circular dependencies between packages.对代码质量设置高标准。Spring框架强调有意义的、当前的、并且准确的java文档。这是为数不多的项目之一,它要求在包之间没有循环依赖清晰的代码结构。

以上出自Spring的文档的Spring Framework Overview

对于第一点而言,Spring确实在各个层次能够整合其他框架,使之发挥更强大的能量,比如在持久层,能够整合MyBatis框架,学过MyBatis都知道,它几乎消除了JDBC中的代码、设置参数和手动获取结果集的工作,使用简单的XML配置文件,将POJO和数据库中的表关联起来。博采众长,这也是Spring如今炙手可热的原因之一吧。

对于第三点,我们知道有向前兼容和向后兼容,一般程序能够向后兼容,这点真的称不上为哲学。

第四点有点吹水成分了,不过确实良好的API造福的是广大Spring使用者。

第五点真是难得,Spring框架的IoC和AOP就能大大地减低程序的耦合性,其本身还自我要求,Spring自己的代码之间清晰、没有之间的依赖,真的是像成绩好的孩子,天天还挑灯夜读,对Spring越来越欣赏了。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值