任何人有使用黑板模式这样的想法? [英] Anyone have thoughts on using the Blackboard Pattern in this way?

查看:166
本文介绍了任何人有使用黑板模式这样的想法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有黑板的概念有什么想法从语用程序员临165?

Does anyone have any thoughts of the Blackboard concept from p.165 of 'The Pragmatic Programmer'?

我想有几个小的子系统(DLL和EXE文件),大多是相互独立的。有一些组件将被用于所有的EXE。这些组件将几乎全部使用同一个数据库。而不是使用接口,这些组件之间的通信,也不会黑板类型模式提供了更多的独立性?

I want to have several small sub-systems (DLLs and EXEs) mostly independent of each other. There are some assemblies that will be used by all EXEs. These assemblies will nearly all use the same database. Rather than using interfaces for communication between these assemblies, wouldn't a Blackboard type pattern provide more independence?

我在想一些中介型构造,通过事件通知以及所有子系统通信都要通过它的。这样可以使SYB-系统非常独立。调解员将持有的所有通知应播放的名称。用户将后来听一个特定事件的名字,但始终订阅相同的(或者是传递名称作为参数)调解员的事件。

I'm thinking of some mediator type construct that notifies via events and all sub-system communication goes through it. This keeps the syb-systems very independent. The mediator will hold the name of all notifications it should broadcast. Subscribers will then listen to a particular event by name but always subscribe to the same (or perhaps pass name as parameter) mediator event.

下面是一些关于它的更多的讨论: HTTP://www.experts -exchange.com/Programming/Languages​​/C_Sharp/Q_22829492.html

Here's some more discussion on it: http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_22829492.html

推荐答案

一黑板的概念是多个独立的进程中运行和更新黑板,因为他们制定出它的一部分。一个典型的例子就是语音识别。该输入数据是音频要被识别。音频可以分割和多线程开始匹配片断的话。因为每个线程发现匹配单词,他们更新与翻译到这一点的黑板。作为短语开始被组装另一个线程可以做语法检查,以验证各个识别器线程将做的选择。如果一个词具有低的信心和违反语法,这块可以重新运行寻找替代品。这甚至可能导致重新分割音频数据口吃和停顿都解决了。

The concept of a blackboard is that multiple independent processes run and update the blackboard as they work out pieces of it. A classic example is speech recognition. The input data is the audio that is to be recognized. The audio can be segmented and multiple threads start matching the snippets to words. As each thread finds matching words, they update the blackboard with the translation up to this point. As phrases start to be assembled another thread can do grammar checking to verify the choices the various recognizer threads are making. If a word has a low confidence and violates the grammar, the piece can be rerun looking for alternatives. This might even result in re-partitioning the audio data as stutters and pauses are resolved.

由于短语成为句子,甚至更大的意见可采取的各种选择同音字(对,削)就可以解决。所有这一切是通过让只有被应用在他们不同的结果滚动黑板上向所有人开放的进程,并锁定完成的。

As the phrases become sentences, even larger views can be taken and the various options for homophones (pair, pare) can be resolved. All of this is done by having the blackboard open to all of the processes and "locks" only being applied as they various results roll in.

使用数据库作为黑板有一定道理,因为你交易免费,但是这将取决于如何积极数据正在更新和重新阅读。如果它发生得很快的往返将增加并作出内存结构更趋合理。

Using a database as your blackboard makes some sense because you get transactions "for free", but it would depend on how aggressively the data is being updated and re-read. If it is happening very quickly the round trips would add up and make an in memory structure more reasonable.

您调停的想法是有道理的,因为它创建了一个单锁点......黑板算法很少遇到A-> B,B-> A风格死锁,因为他们要求所有的数据元素前面。除此之外,在锁定放弃是不是一个大的惩罚,各个子任务将被重新启动所有的时间,因为在数据卷。订户董事会将需要通知时,他们拥有的数据已经过时了,这可能与回调这将重新启动与最新的数据任务来完成。

Your idea of a mediator makes sense as it creates a single lock point... and blackboard algorithms rarely encounter the A->B, B->A style deadlocks because they ask for all the data elements up front. Beyond that, giving up on a lock isn't a large penalty as the various sub-tasks will be restarting all the time as the data rolls in. Subscribers to the board will need to be notified when the data they have has become obsolete, which could be done with callbacks which would restart the task with the newest data.

据有关工作流的注释:这里的主要区别是,大多数工作流程由主的过程,只需进入状态并作出决定,以什么各州可用的数据,中移动的协调。虽然有可能是独立的行动者,他们很少涉足胜过彼此创造更好的成绩(其中其他任务将使用)。换言之,一个工作流通常是非常受限的状态的组数据通过游行,而一黑板几乎是自由的所有独立的活性。 (也就是说,一块黑板可能是您的工作流程背后:<一href="http://sunsite.informatik.rwth-aachen.de/Publications/CEUR-WS/Vol-247/FORUM_15.pdf">http://sunsite.informatik.rwth-aachen.de/Publications/CEUR-WS/Vol-247/FORUM_15.pdf)

As far as the comment about a workflow: the major difference here is that most workflows are coordinated by a master process that takes the state just entered and makes decisions as to what states become available for the data to move within. While there may be independent actors, they rarely get involved in "outdoing" one another by creating better results (which other tasks will then use). In other words, a workflow is usually a very constrained set of states that data marches through, while a blackboard is almost a free-for all of independent activity. (That said, a blackboard could be behind your workflow: http://sunsite.informatik.rwth-aachen.de/Publications/CEUR-WS/Vol-247/FORUM_15.pdf)

我想不出任何C#示例的方式,我所看到的,和工作我没有太多要求它(的计算是确定的)类型。做一些搜索找到其他语言的引用,但没有出现伟大的品质。

I can't think of any C# examples of the pattern that I have seen, and the type of work I do doesn't have much call for it (the computations being deterministic). Doing some searches find references in other languages, but none that appear of great quality.

这篇关于任何人有使用黑板模式这样的想法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆