Monday, April 19, 2010

Software Design Patterns!

Who is Christopher Alexander Anyway?

He was an architect that came up with the concept of patterns. Using the patterns, he would design buildings, roadways etc. Around the year 1990, his concept of patterns was applied to object oriented software design. Eventually, the object-oriented folks realized the influence and importance of patterns and therefore started writing books, articles and workshops to expand on patterns. Finally, with the “Design Patterns” book, patterns gained more acceptance within the object-oriented world.

Pattern?

According to www.handbookofsoftwarearchitecture.com, Christopher Alexander defines a pattern as "a three part rule, which expresses a relation between a certain context, a problem, and a solution". Patterns have many benefits. For example it can be viewed as a way to deal with a recurring problem. Additionally concepts get named and become easier to discuss with a formal written pattern name. As I was reading different sources to write my blog, I came across a good example about pattern languages. I loved the following example I found on a pattern website: “Just as spoken language give people the ability to create an infinite variety of sentences, pattern languages give people the power to create an infinite variety of document types. We just need to create a common vocabulary so we can make useful sentences.”

Patterns are usually divided in the following three groups:
· Creational – patterns that help create (”new”) objects. The Singleton is an example of popular creational pattern.
· Structural –patterns that help with how classes are composed to form larger subsystems.
· Behavior – patterns that help with the inner workings of classes such as algorithms and the responsibility between classes. Template Method is an example of a behavioral pattern.
Some examples of architectural patterns include Layers, MVC, Blackboard System, Peer-to-Peer, Naked objects and etc.

Time for BlackBoard Pattern Example!





I decided to look into the Blackboard architecture pattern. So as mentioned earlier, a pattern is a context, problem and solution. We will follow these in the Blackboard example below:

Context: We have agents that are dedicated to execute a specific subtask of a larger overall task. A medium needs to be established so that it would allow the subtasks to monitor each other and build on their joint progress.

Problem: How are we going to ensure the unity of a group of particular agents?
Solution: With a blackboard, agents can add data, which would allow them to pledge for data changes in their area of interest. Agents can also update data and erase it from the blackboard. The agents continually monitor the blackboard for changes and signal when they want to add, erase or update data.
When multiple agents want to respond to a change, a supervisor agent decides which specialist agent may make a modification to the blackboard.

Here is a role diagram:

Here is another Diagram showing the Interactions that take place between the participants of the Blackboard Pattern:

During my research, I also came across this blackboard example; basically the system supports the design of a hierarchical controller that provides facilities for adaptation, supervision and task planning.



And Last but not least go to http://en.wikipedia.org/wiki/Design_pattern_(computer_science) for additional information on patterns. I find wikipedia extremely useful when it comes to research.

No comments:

Post a Comment