什么是Rails方式(通常明智)(What is the Rails way (convention wise))

系统教程 行业动态 更新时间:2024-06-14 17:03:54
什么是Rails方式(通常明智)(What is the Rails way (convention wise))

在轨道中开发有时被描述为遵循“轨道方式”。 配置约定也是rails中非常重要的一个方面。

但这些具体约定是什么? 以活动记录为例?

Developing in rails is sometimes described as following "the rails way". And convention over configuration is also a very important aspect in rails.

But what are these specific conventions? Using active record for example?

最满意答案

我认为'rails way'或'ruby way'是程序员在Ruby中编写时使用的普遍接受的语法和实践。 所有语言都有类似的“最佳实践”习惯(例如,某些东西是'Pythonic')。

将它与语言或框架使用的实际特征或预期约定区分开来很重要。 这有点像书面语言的语法规则和定义特定类型书写的文体指南之间的差异。

我认为所有语言都有一定的偏见和优势,使得它的某种“风格”编程受到欢迎。 迁移语言的人最初可能会挣扎,因为他们还没有学会如何写这种语言。 例如,许多来自严格OO环境的程序员可能无法理解map() , inject()或lambda在Ruby中工作。

Ruby / Rails中使用的许多约定可能看起来与其他平台不同。 熟悉“ruby方式”的最好方法就是阅读大量源代码并记录人们似乎构建类,例程,文件结构等的方式。

阅读其他人提到的两种“方式”书也不会受到伤害。 我拥有他们两个,他们是很好的资源。

I think the 'rails way' or 'ruby way' is the generally accepted syntax and practices that programmers used when writing in Ruby. All languages have similar sorts of 'best practice' habits (whether or not something is 'Pythonic' for example).

It's important to distinguish it from actual features or expected conventions used by the language or framework. It's kind of like the difference between the grammar rules of a written language and the stylistic guidelines that define a particular type of writing.

I think all languages have certain biases and strengths that make a certain 'style' of programming for it popular. People migrating languages might struggle at first because they haven't learned how to write to that particular language. For example, many programmers coming from a strictly OO environment might have trouble understanding how map(), inject() or lambda work in Ruby.

There's a lot of conventions used in Ruby/Rails that might seem alien to other platforms. The best way to get acquainted with the 'ruby way' is just to read a lot of source code and take notes on the way people seem to be constructing their classes, routines, file structure, etc.

Also reading the two 'Ways' books mentioned by others can't hurt. I own them both, and they're excellent resources.

更多推荐

本文发布于:2023-04-24 14:18:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/d150e9956f4ecba04818ce36b54f101e.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:明智   方式   Rails   convention   wise

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!