.Net 模式与 GOF

发布于 2024-08-03 02:34:32 字数 212 浏览 4 评论 0原文

由于 GOF 书是在 .Net 出现之前就编写完成的,那么 GOF 中描述的特定模式是否有不适合 .Net 的地方?如果是这样,原因是什么?

这是一个与最近的赏金讨论相关的问题。

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? And if so, for what reason?

This is a question relating to a recent bounty discussion.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

咆哮 2024-08-10 02:34:32

GoF 书的想法并不是针对特定语言,尽管他们确实提供了示例来更好地解释设计。

这个想法是提供在软件设计中一次又一次出现的模式,以及一本食谱,任何开发人员都可以根据需要用他们选择的语言来实现这些模式。

也就是说,当您查看 .NET 时,正如其他人所提到的,您将看到一些设计模式在框架中作为一等公民实现。

是否存在因语言而“无用”的情况?不会。即使某些模式已经为您实现,这些模式仍将继续有用。

The idea with the GoF book wasn't to be language-specific, although they did provide samples to better explain the designs.

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.

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.

哆啦不做梦 2024-08-10 02:34:32

C# 3.0 设计模式一书讨论了 .NET 上下文中的原始设计模式。在我看来,它不如原书,但仍然值得一读。

The book C# 3.0 Design Patterns discusses the original design patterns in a .NET context. It is not as good as the original book IMO, but still worth a read.

庆幸我还是我 2024-08-10 02:34:32

嗯,有些用途有限,因为它们已经在框架中实现了。

例如,.NET 中的集合已经支持开箱即用的迭代,因此在大多数情况下您不需要实现迭代器模式。另一个例子是事件,可以使用它来代替自己实现观察者模式。

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. Another example is Events which can be used instead of implementing the Observer pattern yourself.

2024-08-10 02:34:32

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

The GoF patterns tend to apply, in general, to object-oriented languages and, more specifically, to strongly typed languages or to languages with more severe strictures.

森林散布 2024-08-10 02:34:32

不。
即使是 .NET(事件)中的一等公民 Observer 也有其用途,正如最近的 Rx 框架所展示的那样。

No.
Even the Observer which is a first class citizen in .NET (events) has it's uses as the recent Rx Framework shows.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文