<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>behavioral-pattern &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/behavioral-pattern/</link>
	<description>Feed of posts on WordPress.com tagged "behavioral-pattern"</description>
	<pubDate>Sat, 02 Jan 2010 00:03:22 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Template Pattern and Spring]]></title>
<link>http://javavibes.wordpress.com/2009/06/30/template-pattern-and-spring/</link>
<pubDate>Tue, 30 Jun 2009 13:09:41 +0000</pubDate>
<dc:creator>harjitdelhi</dc:creator>
<guid>http://javavibes.wordpress.com/2009/06/30/template-pattern-and-spring/</guid>
<description><![CDATA[As you might be aware, Template is a GoF behavioral pattern. Here I first explain what the Template ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>As you might be aware, Template is a GoF behavioral pattern. Here I first explain what the Template pattern is and then show an example of the pattern as implemented in the Spring framework:</p>
<p>Template works on the philosophy of Abstract classes, wherein the Abstract class implements some boiler plate functionality and let the subclasses implement the specifics.</p>
<p style="font-size:13px;line-height:1.5em;margin:0 0 1em;padding:0;">For example, when you want to execute a JDBC query against a database, you have to implement the following steps:</p>
<ol style="list-style-type:decimal;list-style-position:initial;list-style-image:initial;margin:0 0 0 2em;padding:0;">
<li>Obtain a DataSource</li>
<li>Use the DataSource to get a Connection object</li>
<li>Use the Connection object to create a Statement (or a PreparedStatement)</li>
<li>Execute a query to get the ResultSet</li>
<li>Iterate over the results and create a list of VOs (as an example of a business logic)</li>
<li>Close the ResultSet</li>
<li>Close the Statement</li>
<li>Close the Connection</li>
</ol>
<p style="font-size:13px;line-height:1.5em;margin:0 0 1em;padding:0;">Out of the above steps, most of these are boiler plate code while steps #4 and #5 reflects the actual business logic. If you create a Template class (essentially an Abstract class) that models these steps and allow subclasses to customize the steps #4 and #5 then it will help subclasses reuse the boiler plate code.</p>
<p style="font-size:13px;line-height:1.5em;margin:0 0 1em;padding:0;">Spring does this by providing classes like JdbcTemplate, HibernateTemplate, JmsTemplate etc.  Here is how things work in the Spring world:</p>
<p style="text-align:center;"><img class="size-full wp-image-70 aligncenter" title="template" src="http://javavibes.wordpress.com/files/2009/06/template2.jpg" alt="template" width="374" height="212" /></p>
<pre>Example code:
List results = getHibernateTemplate().executeFind(new HibernateCallback() {
                   public Object doInHibernate(Session session) {
                       Query query = session.createQuery("from Event");
                       query.setMaxResults(2);
                       return query.list();
                   }
});</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Design Pattern - Part 1]]></title>
<link>http://afruj.wordpress.com/2008/07/22/design-pattern-part-1/</link>
<pubDate>Tue, 22 Jul 2008 17:58:09 +0000</pubDate>
<dc:creator>afruj</dc:creator>
<guid>http://afruj.wordpress.com/2008/07/22/design-pattern-part-1/</guid>
<description><![CDATA[In software engineering, a design pattern is a general reusable solution to a commonly occurring pro]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>In <a title="Software engineering" href="http://en.wikipedia.org/wiki/Software_engineering">software engineering</a>, a <strong class="selflink">design pattern</strong> is a general reusable solution to a commonly occurring problem in <a title="Software design" href="http://en.wikipedia.org/wiki/Software_design">software design</a>. A design pattern is not a finished design that can be transformed directly into <a class="mw-redirect" title="Code (computer programming)" href="http://en.wikipedia.org/wiki/Code_%28computer_programming%29">code</a>. It is a description or template for how to solve a problem that can be used in many different situations. <a class="mw-redirect" title="Object-oriented" href="http://en.wikipedia.org/wiki/Object-oriented">Object-oriented</a> design patterns typically show relationships and <a title="Interaction" href="http://en.wikipedia.org/wiki/Interaction">interactions</a> between <a title="Class (computer science)" href="http://en.wikipedia.org/wiki/Class_%28computer_science%29">classes</a> or <a title="Object (computer science)" href="http://en.wikipedia.org/wiki/Object_%28computer_science%29">objects</a>, without specifying the final application classes or objects that are involved.</p>
<p>Patterns originated as an <a title="Pattern (architecture)" href="http://en.wikipedia.org/wiki/Pattern_%28architecture%29"> architectural concept</a> by <a title="Christopher Alexander" href="http://en.wikipedia.org/wiki/Christopher_Alexander">Christopher Alexander</a> (1977/79). In 1987, <a title="Kent Beck" href="http://en.wikipedia.org/wiki/Kent_Beck">Kent Beck</a> and <a title="Ward Cunningham" href="http://en.wikipedia.org/wiki/Ward_Cunningham">Ward Cunningham</a> began experimenting with the idea of applying patterns to <a class="mw-redirect" title="Programming" href="http://en.wikipedia.org/wiki/Programming">programming</a> and presented their results at the <a title="OOPSLA" href="http://en.wikipedia.org/wiki/OOPSLA">OOPSLA</a> conference that year. Design patterns gained popularity in <a title="Computer science" href="http://en.wikipedia.org/wiki/Computer_science">computer science</a> after the book <a title="Design Patterns" href="http://en.wikipedia.org/wiki/Design_Patterns"><em>Design Patterns: Elements of Reusable Object-Oriented Software</em></a> was published in <a title="1994" href="http://en.wikipedia.org/wiki/1994">1994</a>.</p>
<p>Classification:</p>
<p><a title="Design Patterns" href="http://en.wikipedia.org/wiki/Design_Patterns">Design Patterns</a> originally grouped design patterns into the categories <a title="Creational pattern" href="http://en.wikipedia.org/wiki/Creational_pattern">Creational Patterns</a>, <a title="Structural pattern" href="http://en.wikipedia.org/wiki/Structural_pattern">Structural Patterns</a>, and <a title="Behavioral pattern" href="http://en.wikipedia.org/wiki/Behavioral_pattern">Behavioral Patterns</a>, and described them using the concepts of <a class="mw-redirect" title="Delegation (computer science)" href="http://en.wikipedia.org/wiki/Delegation_%28computer_science%29">delegation</a>, <a class="mw-redirect" title="Aggregation (object-oriented programming)" href="http://en.wikipedia.org/wiki/Aggregation_%28object-oriented_programming%29">aggregation</a>, and <a title="Consultation (object-oriented programming)" href="http://en.wikipedia.org/wiki/Consultation_%28object-oriented_programming%29">consultation</a>.</p>
<h2><span class="mw-headline">Creational patterns</span></h2>
<p>These patterns have to do with class instantiation. They can be further divided into class-creation patterns and object-creational patterns. While class-creation patterns use inheritance effectively in the instantiation process, object-creation patterns use delegation to get the job done.</p>
<ul>
<li><a title="Abstract factory pattern" href="http://en.wikipedia.org/wiki/Abstract_factory_pattern">Abstract Factory</a> groups object factories that have a common theme.</li>
<li><a title="Builder pattern" href="http://en.wikipedia.org/wiki/Builder_pattern">Builder</a> constructs complex objects by separating construction and representation.</li>
<li><a title="Factory method pattern" href="http://en.wikipedia.org/wiki/Factory_method_pattern">Factory Method</a> creates objects without specifying the exact class to create.</li>
<li><a title="Prototype pattern" href="http://en.wikipedia.org/wiki/Prototype_pattern">Prototype</a> creates objects by cloning an existing object.</li>
<li><a title="Singleton pattern" href="http://en.wikipedia.org/wiki/Singleton_pattern">Singleton</a> restricts object creation for a class to only one instance.</li>
</ul>
<h2><span class="mw-headline">Structural patterns</span></h2>
<p>These concern class and object composition. They use inheritance to compose interfaces and define ways to compose objects to obtain new functionality.</p>
<ul>
<li><a title="Adapter pattern" href="http://en.wikipedia.org/wiki/Adapter_pattern">Adapter</a> allows classes with incompatible interfaces to work together by wrapping its own interface around that of an already existing class.</li>
<li><a title="Bridge pattern" href="http://en.wikipedia.org/wiki/Bridge_pattern">Bridge</a> decouples an abstraction from its implementation so that the two can vary independently.</li>
<li><a title="Composite pattern" href="http://en.wikipedia.org/wiki/Composite_pattern">Composite</a> composes one-or-more similar objects so that they can be manipulated as one object.</li>
<li><a title="Decorator pattern" href="http://en.wikipedia.org/wiki/Decorator_pattern">Decorator</a> dynamically adds/overrides behaviour in an existing method of an object.</li>
<li><a title="Facade pattern" href="http://en.wikipedia.org/wiki/Facade_pattern">Facade</a> provides a simplified interface to a large body of code.</li>
<li><a title="Flyweight pattern" href="http://en.wikipedia.org/wiki/Flyweight_pattern">Flyweight</a> reduces the cost of creating and manipulating a large number of similar objects.</li>
<li><a title="Proxy pattern" href="http://en.wikipedia.org/wiki/Proxy_pattern">Proxy</a> provides a placeholder for another object to control access, reduce cost, and reduce complexity.</li>
</ul>
<h2><span class="mw-headline">Behavioral patterns</span></h2>
<p>These design patterns are about classes objects communication. They are specifically concerned with communication between <strong>objects</strong>.</p>
<ul>
<li><a title="Chain-of-responsibility pattern" href="http://en.wikipedia.org/wiki/Chain-of-responsibility_pattern">Chain of responsibility</a> delegates commands to a chain of processing objects.</li>
<li><a title="Command pattern" href="http://en.wikipedia.org/wiki/Command_pattern">Command</a> creates objects which encapsulate actions and parameters.</li>
<li><a title="Interpreter pattern" href="http://en.wikipedia.org/wiki/Interpreter_pattern">Interpreter</a> implements a specialized language.</li>
<li><a title="Iterator pattern" href="http://en.wikipedia.org/wiki/Iterator_pattern">Iterator</a> accesses the elements of an object sequentially without exposing its underlying representation.</li>
<li><a title="Mediator pattern" href="http://en.wikipedia.org/wiki/Mediator_pattern">Mediator</a> allows loose coupling between classes by being the only class that has detailed knowledge of their methods.</li>
<li><a title="Memento pattern" href="http://en.wikipedia.org/wiki/Memento_pattern">Memento</a> provides the ability to restore an object to its previous state (undo).</li>
<li><a title="Observer pattern" href="http://en.wikipedia.org/wiki/Observer_pattern">Observer</a> is a publish/subscribe pattern which allows a number of observer objects to see an event.</li>
<li><a title="State pattern" href="http://en.wikipedia.org/wiki/State_pattern">State</a> allows an object to alter its behavior when its internal state changes.</li>
<li><a title="Strategy pattern" href="http://en.wikipedia.org/wiki/Strategy_pattern">Strategy</a> allows one of a family of algorithms to be selected on-the-fly at runtime.</li>
<li><a title="Template method pattern" href="http://en.wikipedia.org/wiki/Template_method_pattern">Template method</a> defines the skeleton of an algorithm as an abstract class, allowing its subclasses to provide concrete behavior.</li>
<li><a title="Visitor pattern" href="http://en.wikipedia.org/wiki/Visitor_pattern">Visitor</a> separates an algorithm from an object structure by moving the hierarchy of methods into one object.</li>
</ul>
<h2><span class="mw-headline">Concurrency patterns</span></h2>
<p><a title="Active Object" href="http://en.wikipedia.org/wiki/Active_Object">Active Object</a>: The Active Object design pattern decouples method execution from method invocation that reside in their own thread of control. The goal is to introduce concurrency, by using asynchronous method invocation and a scheduler for handling requests.</p>
<p><a title="Balking pattern" href="http://en.wikipedia.org/wiki/Balking_pattern">Balking</a>: The Balking pattern is a software design pattern that only executes an action on an object when the object is in a particular state.</p>
<p><a class="mw-redirect" title="Double checked locking pattern" href="http://en.wikipedia.org/wiki/Double_checked_locking_pattern">Double checked locking</a> : Double-checked locking is a software design pattern also known as &#8220;double-checked locking optimization&#8221;. The pattern is designed to reduce the overhead of acquiring a lock by first testing the locking criterion (the &#8216;lock hint&#8217;) in an unsafe manner; only if that succeeds does the actual lock proceed.</p>
<p>The pattern, when implemented in some language/hardware combinations, can be unsafe. It can therefore sometimes be considered to be an anti-pattern.</p>
<p><a title="Guarded suspension" href="http://en.wikipedia.org/wiki/Guarded_suspension">Guarded</a> In concurrent programming, guarded suspension is a software design pattern for managing operations that require both a lock to be acquired and a precondition to be satisfied before the operation can be executed.</p>
<p><a title="Monitor (synchronization)" href="http://en.wikipedia.org/wiki/Monitor_%28synchronization%29">Monitor object</a> A monitor is an approach to synchronize two or more computer tasks that use a shared resource, usually a hardware device or a set of variables.</p>
<p><a class="mw-redirect" title="Read write lock pattern" href="http://en.wikipedia.org/wiki/Read_write_lock_pattern">Read write lock</a> A read/write lock pattern or simply RWL is a software design pattern that allows concurrent read access to an object but requires exclusive access for write operations.</p>
<p><a title="Scheduler pattern" href="http://en.wikipedia.org/wiki/Scheduler_pattern">Scheduler</a> The scheduler pattern is a software design pattern. It is a concurrency pattern used to explicitly control when threads may execute single-threaded code.</p>
<p><a title="Thread pool pattern" href="http://en.wikipedia.org/wiki/Thread_pool_pattern">Thread pool</a> In the thread pool pattern in programming, a number of threads are created to perform a number of tasks, which are usually organized in a queue. Typically, there are many more tasks than threads.</p>
<p><a class="mw-redirect" title="Thread-Specific Storage" href="http://en.wikipedia.org/wiki/Thread-Specific_Storage">Thread-specific storage</a> Thread-local storage (TLS) is a computer programming method that uses static or global memory local to a thread.</p>
<p><a title="Reactor pattern" href="http://en.wikipedia.org/wiki/Reactor_pattern">Reactor</a> The reactor design pattern is a concurrent programming pattern for handling service requests delivered concurrently to a service handler by one or more inputs. The service handler then demultiplexes the incoming requests and dispatches them synchronously to the associated request handlers.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Social Integration of Robots into Groups of Cockroaches to Control Self-Organized Choices]]></title>
<link>http://coffeeandsci.wordpress.com/2007/11/21/social-integration-of-robots-into-groups-of-cockroaches-to-control-self-organized-choices/</link>
<pubDate>Wed, 21 Nov 2007 09:52:22 +0000</pubDate>
<dc:creator>Oldcola</dc:creator>
<guid>http://coffeeandsci.wordpress.com/2007/11/21/social-integration-of-robots-into-groups-of-cockroaches-to-control-self-organized-choices/</guid>
<description><![CDATA[This is probably the cutest experimental setting I read about the last few months (I do know that I ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><span style="float:left;padding:5px;"><a href="http://bpr3.org/?p=52"><img alt="Blogging on Peer-Reviewed Research" src="http://bpr3.org/images/rbicons/ResearchBlogging-Medium-Trans.png" width="80" height="50" /></a></span>This is probably the <em>cutest</em> experimental setting I read about the last few months (I do know that I have a particular understanding of what cute is).<br />Robots, disguised as cockroaches by <em>simple</em> pheromone coating, to make them <em>look like</em> cockroaches, that is at the chemotactility space. Then introduced in a group, to influence dynamically the collective decision-making process. And that works nicely.</p>
<p>More interesting the fact that the programming of robots wasn&#8217;t rigid, so they were influenced by natural individual and acted socially in opposition with their individual preferences.</p>
<p>Autonomous artifacts cooperating with living individuals to solve problems. Far away yet from Asimov&#8217;s robots, but on the right path.<br />Now, who wouldn&#8217;t like to <em>play</em> with such a setting?</p>
<p>Social Integration of Robots into Groups of Cockroaches to Control Self-Organized Choices<br />
J. Halloy, G. Sempo, G. Caprari, C. Rivault, M. Asadpour, F. T&#226;che, I. Sa&#239;d, V. Durier, S. Canonge, J. M. Am&#233;, C. Detrain, N. Correll, A. Martinoli, F. Mondada, R. Siegwart, J. L. Deneubourg<br />
Science 16 November 2007: Vol. 318. no. 5853, pp. 1155 &#8211; 1158 DOI: 10.1126/science.1144259</p>
<p>
<blockquote>Collective behavior based on self-organization has been shown in group-living animals from insects to vertebrates. These findings have stimulated engineers to investigate approaches for the coordination of autonomous multirobot systems based on self-organization. In this experimental study, we show collective decision-making by mixed groups of cockroaches and socially integrated autonomous robots, leading to shared shelter selection. Individuals, natural or artificial, are perceived as equivalent, and the collective decision emerges from nonlinear feedbacks based on local interactions. Even when in the minority, robots can modulate the collective decision-making process and produce a global pattern not observed in their absence. These results demonstrate the possibility of using intelligent autonomous devices to study and control self-organized behavioral patterns in group-living animals.</p></blockquote>
</div>]]></content:encoded>
</item>

</channel>
</rss>
