虽然不是纯粹的 OOD 原则 - 应该DRY 在考虑 SOLID原则?如果不是——为什么不呢?
Although not a pure OOD principle - should DRY also be included when thinking about SOLID principles? If not - why not?
这有点像问为什么你不应该在一篮子苹果中添加活动扳手:它们实际上并不是同一件事。
SOLID 是一组专门针对面向对象设计的原则。
我想说,DRY 与这些有些正交——它是一种可以应用于您编写的任何内容的编程原则。
(话虽如此,这个缩写词简直太好了,不容错过)
It's a bit like asking why you shouldn't add a monkey-wrench to a basket of apples: they're not really the same thing.
SOLID is a set of principles that specifically address object-oriented design.
DRY is, I'd say, somewhat orthogonal to those - it's a programming principle that can apply to anything you write.
(Having said that, the acronym is almost too good to pass up on)
我认为“DRY”可能不够具体,不足以使其成为SOLID。 “DRY”可能是其他原则的基本原则,它适用于任何类型的开发,而不仅仅是像 SOLID 那样的面向对象开发。
I think "DRY" is probably not specific enough to make it into SOLID. "DRY" might be an underlying principle of the other principles, and it applies to any kind of development, not just object-oriented development, like SOLID does.
SOLID 拥抱 DRY。如果你坚持 SOLID 原则,那么你几乎自然而然就会 DRY。
SOLID embraces DRY. If you ahdhere to the SOLID principles you are almost automatically DRY.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(3)
这有点像问为什么你不应该在一篮子苹果中添加活动扳手:它们实际上并不是同一件事。
SOLID 是一组专门针对面向对象设计的原则。
我想说,DRY 与这些有些正交——它是一种可以应用于您编写的任何内容的编程原则。
(话虽如此,这个缩写词简直太好了,不容错过)
It's a bit like asking why you shouldn't add a monkey-wrench to a basket of apples: they're not really the same thing.
SOLID is a set of principles that specifically address object-oriented design.
DRY is, I'd say, somewhat orthogonal to those - it's a programming principle that can apply to anything you write.
(Having said that, the acronym is almost too good to pass up on)
我认为“DRY”可能不够具体,不足以使其成为SOLID。 “DRY”可能是其他原则的基本原则,它适用于任何类型的开发,而不仅仅是像 SOLID 那样的面向对象开发。
I think "DRY" is probably not specific enough to make it into SOLID. "DRY" might be an underlying principle of the other principles, and it applies to any kind of development, not just object-oriented development, like SOLID does.
SOLID 拥抱 DRY。如果你坚持 SOLID 原则,那么你几乎自然而然就会 DRY。
SOLID embraces DRY. If you ahdhere to the SOLID principles you are almost automatically DRY.