一位同事从未听说过这个词,我也无法给出一个确切的定义。对我来说,这一直是一个“我看到什么就知道什么”的例子。
附带问题,这个词是谁发明的?
一位同事从未听说过这个词,我也无法给出一个确切的定义。对我来说,这一直是一个“我看到什么就知道什么”的例子。
附带问题,这个词是谁发明的?
当前回答
您可以将其称为“片段”,或者更准确地称为“片段的集合”。 我认为这个术语是由新闻界和印刷业创造出来的,在那里他们使用实际的“板块”,然后再次将它们用作大块。 在现代互联网上,这是一个正在进行的(恕我冒犯)趋势的一部分,使用花哨的术语来描述简单的东西,以便看起来更时尚和复杂。参见响应性=适应性/流动性。
其他回答
重复的代码只会增加不必要的输入层来完成工作。
这些是必要的吗?
在大多数情况下,这些都是结构和装饰性的标记。它提供了代码、函数和语言的一致性。
因此,对于开发人员来说,它有点多余,因为我们已经见过它很多次了,但它确实向非开发人员和编译器传达了一些实际意义。
它是可以被许多应用程序/上下文使用的代码,只需很少或没有更改。
样板纸(Boilerplate)起源于20世纪初的钢铁工业。
在词源上,术语boilerplate: from http://www.takeourword.com/Issue009.html…
Interestingly, the term arose from the newspaper business. Columns and other pieces that were syndicated were sent out to subscribing newspapers in the form of a mat (i.e. a matrix). Once received, boiling lead was poured into this mat to create the plate used to print the piece, hence the name boilerplate. As the article printed on a boilerplate could not be altered, the term came to be used by attorneys to refer to the portions of a contract which did not change through repeated uses in different applications, and finally to language in general which did not change in any document that was used repeatedly for different occasions.
编程中的样板文件由什么组成?正如其他人可能已经指出的那样,它 只是一大块代码,一遍又一遍地复制,很少或 在这个过程中没有对它做任何改变。
Joshua Bloch有一个关于API设计的演讲,涵盖了糟糕的API如何使样板代码成为必要。(参考样板文件的第46分钟,今天听这个)
样板文件是一种写作单元,可以不作任何更改地反复使用。通过扩展,这种思想有时应用于可重用编程,如“样板代码”