如果你在一个系统里两次以上重复了相同的代码,那么这个系统的设计是可以改进的。这就是众周所知的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.一次且仅一次
"在编写代码时应用 一次且仅一次原则 比实施后容易的多,整合两个类似的函数是相当困难的!"
本文介绍了软件开发中的DRY(Don't Repeat Yourself)原则及其变种Once and Only Once原则,强调了代码复用的重要性,并提供了避免代码重复的具体指导,有助于保持代码的灵活性与实用性。
1262

被折叠的 条评论
为什么被折叠?



