简体   繁体   English

.Net模式与GOF

[英].Net patterns vs. GOF

Since the GOF book was put together well before .Net came into being, are there any specific patterns described in GOF that are not appropriate for .Net? 由于GOF书籍在.Net出现之前很好地组合在一起,GOF中描述的特定模式是否适合.Net? And if so, for what reason? 如果是这样,出于什么原因?

This is a question relating to a recent bounty discussion . 这是一个与最近的赏金讨论有关的问题。

The idea with the GoF book wasn't to be language-specific, although they did provide samples to better explain the designs. GoF书中的想法不是针对特定语言的,尽管他们确实提供了样本以更好地解释设计。

The idea was to provide patterns which appear again and again in software design, and something of a cookbook that any developer can use to implement those patterns as needed in their language of choice. 我们的想法是提供在软件设计中一次又一次出现的模式,以及任何开发人员可以根据需要以所选语言实现这些模式的烹饪书。

That said, when you look at .NET, as others have mentioned, you will see several of the design patterns implemented as first-class citizens right in the framework. 也就是说,当你看到.NET时,正如其他人所提到的那样,你会看到几个设计模式在框架中被实现为一等公民。

Are there any "not of use" because of a language? 因语言而有“不使用”吗? No. The patterns will continue to be useful, even if some are already implemented for you. 不会。这些模式将继续有用,即使已经为您实施了一些模式。

The book C# 3.0 Design Patterns discusses the original design patterns in a .NET context. C#3.0 Design Patterns一书讨论了.NET上下文中的原始设计模式。 It is not as good as the original book IMO, but still worth a read. 它不如IMO原书那么好,但仍然值得一读。

Well, some have limited use because they are already implemented in the framework. 嗯,有些用途有限,因为它们已经在框架中实现。

For example, collections in .NET already support iteration out-of-the-box, so you wouldn't need to implement the Iterator pattern in most cases. 例如,.NET中的集合已经支持开箱即用的迭代,因此在大多数情况下您不需要实现Iterator模式。 Another example is Events which can be used instead of implementing the Observer pattern yourself. 另一个例子是可以使用的事件,而不是自己实现Observer模式。

一般而言,GoF模式通常适用于面向对象的语言,更具体地说,适用于强类型语言或具有更严格限制的语言。

没有。即使是.NET(事件)中的一等公民观察者也有它作为最近的Rx框架显示的用途。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM