Rails 部件背后的命名规则是什么? [英] What is the naming rule behind Rails' parts?

查看:38
本文介绍了Rails 部件背后的命名规则是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

某些 Rails 部分以Active"开头:

Some Rails' parts start with "Active":

  • 活动记录
  • 主动模型
  • 主动支持

Rails 的一些部分以Action"开头:

And some Rails' parts start with "Action":

  • 动作包
  • 动作视图
  • ActionMailer

这是为什么?为什么它们没有相同的前缀?在这种情况下,主动"和行动"是什么意思?

Why is that? Why don't they all have the same prefix? And what do "Active" and "Action" mean in this context?

DHH 现在正在构建ActiveJob",他怎么知道它不应该是ActionJob"?

DHH is now building "ActiveJob", and how did he know if it wasn't supposed to be "ActionJob"?

推荐答案

我的看法,这只是我的观点(唯一能给出确认答案的人是 DHH :) ),

The way I look at it, again this is just my perspective (the only person who can give a confirmed answer is DHH :) ),

当我看到 Action* 就像 ActionPack(ActionViewActionController 的两个主要组件>ActionPack) 或 ActionMailer,它们属于在 Rails 应用程序中执行的动作,无论是控制器特定的动作还是显示特定的视图,甚至是发送电子邮件.所以,Action 在这里似乎是精确的前缀,因为这些包表示做某事.

When I see Action* like ActionPack (ActionView and ActionController are the two major components of ActionPack) or ActionMailer, they pertain to an action performed within the Rails application be it a controller specific action or displaying a particular view or even sending an email. So, Action seems precise prefix here as these packages denote doing something.

当我看到 Active*ActiveRecordActiveSupportActiveModel 等时,它以某种方式与提供一些对您的 Rails 应用程序业务逻辑有用的功能,可以是实用程序方法或 ORM 支持(类似于附加组件)以促进 Rails 应用程序开发.

When I see Active* like ActiveRecord, ActiveSupport or ActiveModel etc., it somehow relates to providing some useful functionality to your Rails applications business logic be it utility methods or ORM support kind of like add-ons to facilitate the Rails application development.

希望在这个问题上看到更多有趣的答案.这是我们可以开始分析的地方.

Hope to see more interesting answers on this question. This is where we can start analyzing.

这篇关于Rails 部件背后的命名规则是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆