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

如果你在一个系统里两次以上重复了相同的代码,那么这个系统的设计是可以改进的。这就是众周所知的DRY法则~~~

 

1, Don't Repeat Yourself

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

 

2.On ce and On ly On ce

"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.一次且仅一次

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

 

 

 

你可能感兴趣的:(编程)