一位同事从未听说过这个词,我也无法给出一个确切的定义。对我来说,这一直是一个“我看到什么就知道什么”的例子。
附带问题,这个词是谁发明的?
一位同事从未听说过这个词,我也无法给出一个确切的定义。对我来说,这一直是一个“我看到什么就知道什么”的例子。
附带问题,这个词是谁发明的?
当前回答
样板文件是一种写作单元,可以不作任何更改地反复使用。通过扩展,这种思想有时应用于可重用编程,如“样板代码”
其他回答
简而言之,样板代码是需要包含在应用程序中的重复代码,程序/框架几乎没有改变,并且对应用程序的逻辑没有任何贡献。当您编写伪代码时,您可以删除样板代码。建议使用合适的Editor来生成样板代码。
在HTML中,接口中的样板代码。
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body> </body>
</html>
在c#语言中,属性的样板代码。
class Price
{
private string _price;
public string Price
{
get {return _price;}
set {_price= value;}
}
}
从维基百科:
在计算机编程中,样板文件是用来描述必须包含在许多地方且很少或没有更改的代码段的术语。它更常用于被认为是冗长的语言,即程序员必须编写大量代码来完成最少的工作。
所以基本上,你可以把样板代码看作是一种编程语言所需要的文本,在你用这种语言编写的程序中经常用到。
现代语言正在尝试减少它,但旧的语言也有特定的类型检查器(例如OCaml有一个类型推断器,它允许您避免在像Java这样更冗长的语言中作为样板代码的太多声明)
Boilerplate definition is becoming more global in many other programming languages nowadays. It comes from OOP and hybrid languages that have become OOP and were before procedual have now the same goal to keep repeating the code you build with a model/template/class/object hence why they adapt this term. You make a template and the only things you do for each instance of a template are the parameters to individualize an object this part is what we call boilerplate. You simply re-use the code you made a template of, just with different parameters.
同义词 蓝图是样板 模板是样板 页脚是一个样板 用于多种用途的设计模式是一个样板 邮件的签名是一份样板文件
它是可以被许多应用程序/上下文使用的代码,只需很少或没有更改。
样板纸(Boilerplate)起源于20世纪初的钢铁工业。
来自whatis.techtarget.com:
In information technology, a boilerplate is a unit of writing that can be reused over and over without change. By extension, the idea is sometimes applied to reusable programming as in "boilerplate code." The term derives from steel manufacturing, where boilerplate is steel rolled into large plates for use in steam boilers. The implication is either that boilerplate writing has been time-tested and strong as "steel," or possibly that it has been rolled out into something strong enough for repeated reuse.
编程之外:
样板可以与特定类型的模板进行比较 被认为是一个填空样板。一些典型的 样板文件通常包括:任务陈述、安全警告 使用的安装程序、版权声明和责任 免责声明。
以我作为程序员的经验来看,合适的样板代码通常是一堆你开始的代码,这些代码不太大,也不太复杂,不能称为框架。
HTML5 Boilerplate就是一个典型的例子。