编程法则 - DRY(Don't Repeat Yourself)

来源:互联网 发布:MP3音序软件 编辑:程序博客网 时间:2024/05/19 02:42

1,Don't Repeat Yourself

''Every piece of knowledge must have a single, unambiguous, authoritative representation within a system"

2.Once and Only Once

"Once and Only Once is much easier to apply as you write code than after the fact. It is very difficult to tease together two similar functions"

If you keep this principle in mind as you code it will help you keep your code supple and useful so it may live long and prosper

1.别自我重复

"每一部分知识必须唯一,明确,可靠的表现在一个系统里"

2.一次且仅一次

"在编写代码时应用 一次且仅一次原则 比实施后容易的多,整合两个类似的函数是相当困难的!"

如果你在编写代码的时候坚持这个原则,他将帮助你的代灵活而有用,而你的代码也会存活的长久兴旺!