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

Ruby Rails的设计哲学

2011年04月26日 ⁄ 综合 ⁄ 共 1056字 ⁄ 字号 评论关闭

Rails把java的方式戏称为XML仰卧起坐(sit-ups)。

Rails是一个完整的,开源的web开发框架,更多的快乐和更少的代码。

贯穿整个框架的是DRY(不要重复)原则,具体体现比如:定义好数据库表后,类名字和对象属性名字都自动确定了。用过hibernate的朋友知道我在说什么(你也许会说xdoclet, 那不也得学吗)。

学习成本低,不需要学习各种XML花式(学习过struts,spring,hiber,webwork,ant,maven的朋友知道我在说什么),只需要学习Ruby语言就够了。

编程的快乐又回来了,没有编译和部署,即改即得,所有的复杂都隐藏在框架内部了。

你感受到它的哲学了吗?自己安装试试看吧。

===========================================

作为对照,以下文字来自rails网站首页:

Rails is a full-stack, open-source web framework in Ruby for writing real-world applications with joy and less code than most frameworks spend doing XML sit-ups

Being a full-stack framework means that all layers are built to work seamlessly together. That way you Don’t Repeat Yourself (DRY) and you can use a single language from top to bottom. Everything from templates to control flow to business logic is written in Ruby—the language of love for industry heavy-weights.

In striving for DRY compliance, Rails shuns configuration files and annotations in favor of reflection and run-time extensions.

This means the end of XML files telling a story that has already been told in code. It means no compilation phase: Make a change, see it work. Meta-data is an implementation detail left for the framework to handle.

抱歉!评论已关闭.