如何从事件驱动的模型的观察者模式有什么不同?观察者、有什么不同、模型、模式

2023-09-03 09:42:46 作者:沵旳温暖ご

我是一个高级别的开发者,但我还没有很多正式的训练,我的,虽然我已经使用了许多的设计模式,并看到他们在我多年作为一个开发者,没有人真正走出自己的方式来表达。 哦,这是一个观察者模式,或者这是一个单例模式。

I am a senior level developer but I haven't had a lot of formal training and I although I have used many design patterns and seen them used in my years as a developer, no one really went out of their way to say. "Oh this is an observer pattern, or this is a Singleton pattern."

读了一些设计模式,我遇到了观察者模式,它似乎是非常相似的.NET框架事件的工作方式。我失去了一些有关这一根本?

Reading over some of the design patterns, I came across the Observer pattern and it seems to be to be very similar to the way the .NET framework events work. Am I missing something fundamental about this?

推荐答案

在.NET事件模型是pretty的公共语言运行库的观察者模式太大的综合实施。在.NET语言直接在他们的语言特定的方式实现观测,利用这个框架的内置支持。

The .NET Event model is pretty much a integrated implementation of the observer pattern in the common language runtime. The .NET languages implement observer directly in their language specific manner, using the framework's built-in support for this.

在大多数编程语言中,观察者模式需要定制开发或库。

In most programming languages, the observer pattern requires customized development or libraries.

它配备了免费的在C#,VB.NET和建成使用CLR的大多数其他语言的语言的一部分。

It comes for free as part of the language in C#, VB.NET and most other languages built to use the CLR.