Link to home
Start Free TrialLog in
Avatar of sapbucket
sapbucket

asked on

C# Blackboards

Hello,

 I'm reading "The Pragmatic Programmer" [Hunt, Thomas] and p.165 there is a small section about "Blackboards". I read the chapter to learn about MVC and the author claims there is a better way: "Blackboard". He also states that "Blackboards" are a better solution than workflows. We use workflows at work and I've never heard about "Blackboards" being a better option.

My question: does anyone know where I can find code examples (in C#) that demonstrate a "Blackboard" in action? Also, I couldn't find anything useful on the web - if you could point me towards some useful FAQs or discussion forums I would accept that as an answer.

Thanks,
sapbucket
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Blackboard architecture has been around for a while, but I don't hear it talked about very much (oddly enough).  It has it roots in Artificial Intelligence, and has a focus on sharing information from a central place.

There are some good resources for explaining Blackboards (that you may or may not have found):

Blackboard Architecture
http://www.nb.net/~javadoug/bb.htm

Blackboard Pattern
http://vico.org/pages/PatronsDisseny/Pattern%20Blackboard/

Bob
I haven't really compared and contrasted the differences between workflows and blackboards, but they seem like different architectures on the surface.  I would be interested to hear the opinion raised by the book's author that says that one is "better" than the other.  Workflows are procedural, and talk about steps, and blackboards are about collecting information to make informed decisions.

Bob
Avatar of sapbucket
sapbucket

ASKER

Right! That's what I thought too. It seems like comparing apples and oranges.

The author gives an example: mortgage loan applications. These are notorious for having many regulations (business logic) that stem from federal, state, and local regulations. These regulatory bodies are conceptually independent of each other, that is, a designer would probable make three workflows: one for federal, one for state, one for local. So three sets of workflow logic.

What happens though if the workflows create situational dependencies?

For example, "a veteran applies for a VA home mortgage. This is done through a federal agency. The federal law states that the veteran must get a medical exam to demonstrate he is healthy enough to pay off the mortgage over it's lifetime. The veteran goes to the local hospital to get a medical exam. He then finds out that state law states that medical exams for the purpose of loan qualification can be deducted from state taxes."

Federal -> request a mortgage -> get medical exam -> receive a mortgage
State -> get medical exam -> submit proof mortgage application -> get tax deduction

I don't know if a workflow could solve this problem. If we think of the veteran as an object that "wants to follow the federal workflow", how would that object ever receive information from the State workflow about getting the tax deduction?

It seems like we would then have to modify the federal workflow, that is, add a decisional branch "IF veteran AND applying for mortgage AND required to have medical exam AND State law allows tax deduction" THEN "veteran receive state tax deduction".

Messy! I could see how heterogeneous systems (like this example) would not work with workflows. It would create a messy set of interdependencies. And if the law changes (which it will) then a programmer would have to go and change the workflows and update the interdependencies. Not a fun job!

What I think the author is saying in "The Pragmatic Programmer" is that a Blackboard pattern takes care of this problem. It would solve the above by adding a listener to the StateGovernment object. The listener would be programmed to listen to all messages on the blackboard (from any source) for the messages "mortgage", "veteran", and "medical exam" used in conjunction or in sequence. If it "hears" these messages then it will respond and send out it's own message to the veteranObject: "apply for state tax deduction". Or it could respond to the FederalGovernment object with "ADD apply for state tax deduction TO veteranObject EventSequence". Or something like that. I'm not sure I understand the pattern.

Care to elaborate anyone? I would like to understand this pattern more and especially how it compares to workflows.

Thanks,
sapbucket
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sapbucket, sorry if it looks like I am asking my own question here .. if so, please do let me know and I will post my own and I will request Bob to comment there ..

Bob,
>>any pattern that centers around a publish/subscriber/listener (Observer) is a great one in my book, since it limits the interdependencies.
why do you say that and how will implement such a design in a web application? I have always been confused with the design pattersn, esp with its implementation in a web scneario. In a web application, the state is not maintained right? so even with a blackboard architecture, what would the listner be actually implemented as .. most of the articles and books will take some standard examples to explain this and I have not been able to see a end to end solution wchich deals with a practical problem and solution using these pattterns .. especially a web application ..

Sorry again sapbucket ..

Rejo
Nope, no problem. I'm all about learning!
Bob is a good teacher - I frequently venture off the deep end and someone like Bob reins me back in

as far as my question goes I am still looking over the replies and hoping for more