<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4345824448663422013</id><updated>2024-09-09T22:25:56.229+01:00</updated><category term="Eclipse"/><category term="coding tips"/><category term="java"/><category term="refactoring"/><category term="J2EE"/><category term="architecture"/><category term="design patterns"/><category term="application"/><category term="bookmarking"/><category term="content assistant"/><category term="environment"/><category term="fun"/><category term="intercepting filter"/><category term="interceptor"/><category term="maven"/><category term="team"/><title type='text'>bosy.DailyDev.org</title><subtitle type='html'>Blog about practises and challanges in daily software developer&#39;s work such a tools usage, architecture and design, project management, configuration management and others.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://bosy.dailydev.org/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4345824448663422013/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://bosy.dailydev.org/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Roman B.</name><uri>http://www.blogger.com/profile/10191921864885167276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4345824448663422013.post-8312774378006739114</id><published>2009-02-17T16:03:00.001+01:00</published><updated>2009-02-17T16:37:22.122+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="maven"/><title type='text'>Speed up Maven build</title><content type='html'>&lt;span style=&quot;font-weight: bold;font-size:85%;&quot; &gt;From a sprint retrospective we got a lot of &#39;minuses&#39; related to the speed of Maven build executed by every developer localy on their computers many times per day. The developers were frustrated that complete build tooks from 10 to 15 minutes and estimated that they spend from 30 to 60 minutes every day just waiting for build. What in a team containing 16 developers (it was two scrum teams) gives you from 8 to 16 manhours per day. It is really a lot so we decided to try to do something about it.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;At the begining I have to say that if there is such problem in the project, it usualy mean that something is wrong with modularity, or your IDE should be replaced or used in a better way to support faster code-see iterations. But it wasn&#39;t true in our case. Our problem was legacy web application famework without any support in existing IDEs.&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;Since I was responsible for build process I started to work on this issue. At the first I started to talk with developers about how do they build it. They simply used the most common way of application building:&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;cmd&quot;&gt;mvn clean install&lt;/div&gt;&lt;br /&gt;to rebuild this all, or&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;cmd&quot;&gt;mvn install&lt;/div&gt;&lt;br /&gt;to just repack updated sources and resources.&lt;br /&gt;&lt;br /&gt;So I started to &quot;profile&quot; the build and early found surprising fact that&lt;span style=&quot;font-weight: bold;&quot;&gt; approximately 50% of the time is taken by &#39;clean&#39; goal&lt;/span&gt; - I found first bottleneck.&lt;br /&gt;&lt;br /&gt;To remove it I used simple trick - &lt;span style=&quot;font-weight: bold;&quot;&gt;move/rename&lt;/span&gt; operation on the folder is immediate on most of the systems in comparison with &lt;span style=&quot;font-weight: bold;&quot;&gt;delete&lt;/span&gt; operation.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;xml&quot;&gt;...&lt;br /&gt;&amp;lt;profile&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;id&amp;gt;&lt;span class=&quot;content&quot;&gt;qclean&lt;/span&gt;&amp;lt;/id&amp;gt;&lt;br /&gt;&amp;lt;build&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;plugins&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;plugin&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;groupId&amp;gt;&lt;span class=&quot;content&quot;&gt;org.apache.maven.plugins&lt;/span&gt;&amp;lt;/groupId&amp;gt;&lt;br /&gt;&amp;lt;artifactId&amp;gt;&lt;span class=&quot;content&quot;&gt;maven-antrun-plugin&lt;/span&gt;&amp;lt;/artifactId&amp;gt;&lt;br /&gt;&amp;lt;executions&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;execution&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;id&amp;gt;&lt;span class=&quot;content&quot;&gt;rename_target&lt;/span&gt;&amp;lt;/id&amp;gt;&lt;br /&gt;&amp;lt;phase&amp;gt;&lt;span class=&quot;content&quot;&gt;pre-clean&lt;/span&gt;&amp;lt;/phase&amp;gt;&lt;br /&gt;&amp;lt;goals&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;goal&amp;gt;&lt;span class=&quot;content&quot;&gt;run&lt;/span&gt;&amp;lt;/goal&amp;gt;&lt;/div&gt;&amp;lt;/goals&amp;gt;&lt;br /&gt;&amp;lt;configuration&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;tasks&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;tstamp&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;format &lt;span class=&quot;attr&quot;&gt;property=&lt;span class=&quot;val&quot;&gt;&quot;targetTstamp&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class=&quot;linesplit&quot;&gt;&lt;span class=&quot;attr&quot;&gt;pattern=&lt;span class=&quot;val&quot;&gt;&quot;yyyyMMdd-HHmmss&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;locale=&lt;span class=&quot;val&quot;&gt;&quot;en,US&quot;&lt;/span&gt;&lt;/span&gt; /&amp;gt;&lt;/div&gt;&lt;/div&gt;&amp;lt;/tstamp&amp;gt;&lt;br /&gt;&amp;lt;move &lt;span class=&quot;attr&quot;&gt;todir=&lt;span class=&quot;val&quot;&gt;&quot;trash/target-${targetTstamp}&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class=&quot;linesplit&quot;&gt;&lt;span class=&quot;attr&quot;&gt;failonerror=&lt;span class=&quot;val&quot;&gt;&quot;false&quot;&lt;/span&gt;&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;fileset &lt;span class=&quot;attr&quot;&gt;dir=&lt;span class=&quot;val&quot;&gt;&quot;target/&quot;&lt;/span&gt;&lt;/span&gt; /&amp;gt;&lt;/div&gt;&amp;lt;/move&amp;gt;&lt;/div&gt;&amp;lt;/tasks&amp;gt;&lt;br /&gt;&lt;/div&gt;&amp;lt;/configuration&amp;gt;&lt;/div&gt;&amp;lt;/execution&amp;gt;&lt;/div&gt;&amp;lt;/executions&amp;gt;&lt;/div&gt;&amp;lt;/plugin&amp;gt;&lt;/div&gt;&amp;lt;/plugins&amp;gt;&lt;/div&gt;&amp;lt;/build&amp;gt;&lt;/div&gt;&amp;lt;/profile&amp;gt;&lt;br /&gt;...&lt;/div&gt;&lt;br /&gt;In the code snapshot you can see definition of new &lt;span style=&quot;font-style:italic;&quot;&gt;qclean&lt;/span&gt; (means Quick Clean) profile. The profile contains configuration of &lt;a href=&quot;http://maven.apache.org/plugins/maven-antrun-plugin/&quot;&gt;maven-antrun-plugin&lt;/a&gt; to be executed in a &#39;pre-clean&#39; phase. The Ant script at the first generates a timestamp string into a property &#39;targetTimestamp&#39; using &#39;tstamp&#39; task. Then it moves and renames &#39;target&#39; folder to &#39;trash/target-${targetTstamp}&#39;.&lt;br /&gt;&lt;br /&gt;Now when developers executed build using following command they simply spent just half of the time waiting for build.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;cmd&quot;&gt;mvn clean install -Pqclean&lt;/div&gt;&lt;br /&gt;Because the &#39;target&#39; folder is just moved and not deleted it is necessary to clean also &#39;trash&#39; folder sometimes. But you can do it as a background operation or while you are not using the computer at all. For this purpose I created one more profile named &lt;span style=&quot;font-style:italic;&quot;&gt;clean.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;xml&quot;&gt;...&lt;br /&gt;&amp;lt;profile&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;id&amp;gt;&lt;span class=&quot;content&quot;&gt;clean&lt;/span&gt;&amp;lt;/id&amp;gt;&lt;br /&gt;&amp;lt;build&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;plugins&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;plugin&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;groupId&amp;gt;&lt;span class=&quot;content&quot;&gt;org.apache.maven.plugins&lt;/span&gt;&amp;lt;/groupId&amp;gt;&lt;br /&gt;&amp;lt;artifactId&amp;gt;&lt;span class=&quot;content&quot;&gt;maven-antrun-plugin&lt;/span&gt;&amp;lt;/artifactId&amp;gt;&lt;br /&gt;&amp;lt;executions&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;execution&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;id&amp;gt;&lt;span class=&quot;content&quot;&gt;clean_trash&lt;/span&gt;&amp;lt;/id&amp;gt;&lt;br /&gt;&amp;lt;phase&amp;gt;&lt;span class=&quot;content&quot;&gt;clean&lt;/span&gt;&amp;lt;/phase&amp;gt;&lt;br /&gt;&amp;lt;goals&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;goal&amp;gt;&lt;span class=&quot;content&quot;&gt;run&lt;/span&gt;&amp;lt;/goal&amp;gt;&lt;/div&gt;&amp;lt;/goals&amp;gt;&lt;br /&gt;&amp;lt;configuration&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;tasks&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;delete &lt;span class=&quot;attr&quot;&gt;dir=&lt;span class=&quot;val&quot;&gt;&quot;trash/&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;failonerror=&lt;span class=&quot;val&quot;&gt;&quot;false&quot;&lt;/span&gt;&lt;/span&gt; /&amp;gt&lt;/div&gt;&amp;lt;/tasks&amp;gt;&lt;br /&gt;&lt;/div&gt;&amp;lt;/configuration&amp;gt;&lt;/div&gt;&amp;lt;/execution&amp;gt;&lt;/div&gt;&amp;lt;/executions&amp;gt;&lt;/div&gt;&amp;lt;/plugin&amp;gt;&lt;/div&gt;&amp;lt;/plugins&amp;gt;&lt;/div&gt;&amp;lt;/build&amp;gt;&lt;/div&gt;&amp;lt;/profile&amp;gt;&lt;br /&gt;...&lt;/div&gt;&lt;br /&gt;It can be executed using following command.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;cmd&quot;&gt;mvn clean -Pclean&lt;/div&gt;&lt;br /&gt;During second profiling round I found again that there is 50% of time consumed by tasks which are without any use during quick code-see development. The tasks were unit tests (please do not beat me, I can explain it ;-), integration tests, unit test coverage, checkstyle, findbugs, and other checks.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Those task of course should be performed before every commit to SCM, or the continuous integration build will fail, if there are some violations.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;What I wanted, was one more profile - &lt;span style=&quot;font-style:italic;&quot;&gt;qbuild&lt;/span&gt; - which will disable those tasks if active. The reason why I didn&#39;t want to include it in already existing &lt;span style=&quot;font-style:italic;&quot;&gt;qclean&lt;/span&gt; profile was that sometimes developers want to run build with &lt;span style=&quot;font-style:italic;&quot;&gt;qclean&lt;/span&gt; profile, but also wants to have all those checks enabled.&lt;br /&gt;&lt;br /&gt;Switching off the unit tests is simple.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;xml&quot;&gt;...&lt;br /&gt;&amp;lt;profile&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;id&amp;gt;&lt;span class=&quot;content&quot;&gt;qbuild&lt;/span&gt;&amp;lt;/id&amp;gt;&lt;br /&gt;&amp;lt;properties&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;maven.test.skip&amp;gt;&lt;span class=&quot;content&quot;&gt;true&lt;/span&gt;&amp;lt;/maven.test.skip&amp;gt;&lt;/div&gt;&amp;lt;/properties&amp;gt;&lt;br /&gt;&lt;/div&gt;&amp;lt;profile&amp;gt;&lt;br /&gt;...&lt;/div&gt;&lt;br /&gt;It will neither compile them.&lt;br /&gt;&lt;br /&gt;To switch off other stuff I had to know ids of the executions used to configure plugins within the build process definition.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;xml&quot;&gt;...&lt;br /&gt;&amp;lt;plugin&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;groupId&amp;gt;&lt;span class=&quot;content&quot;&gt;org.codehaus.mojo&lt;/span&gt;&amp;lt;/groupId&amp;gt;&lt;br /&gt;&amp;lt;artifactId&amp;gt;&lt;span class=&quot;content&quot;&gt;cobertura-maven-plugin&lt;/span&gt;&amp;lt;/artifactId&amp;gt;&lt;br /&gt;&amp;lt;executions&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;execution&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;id&amp;gt;&lt;span class=&quot;content&quot;&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;verify-coverage&lt;/span&gt;&lt;/span&gt;&amp;lt;/id&amp;gt;&lt;br /&gt;&amp;lt;phase&amp;gt;&lt;span class=&quot;content&quot;&gt;verify&lt;/span&gt;&amp;lt;/phase&amp;gt;&lt;br /&gt;&amp;lt;goals&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;goal&amp;gt;&lt;span class=&quot;content&quot;&gt;check&lt;/span&gt;&amp;lt;/goal&amp;gt;&lt;br /&gt;&lt;/div&gt;&amp;lt;/goals&amp;gt;&lt;br /&gt;&lt;/div&gt;&amp;lt;/execution&amp;gt;&lt;br /&gt;&lt;/div&gt;&amp;lt;/executions&amp;gt;&lt;br /&gt;&lt;/div&gt;&amp;lt;/plugin&amp;gt;&lt;br /&gt;&amp;lt;plugin&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;groupId&amp;gt;&lt;span class=&quot;content&quot;&gt;org.apache.maven.plugins&lt;/span&gt;&amp;lt;/groupId&amp;gt;&lt;br /&gt;&amp;lt;artifactId&amp;gt;&lt;span class=&quot;content&quot;&gt;maven-checkstyle-plugin&lt;/span&gt;&amp;lt;/artifactId&amp;gt;&lt;br /&gt;&amp;lt;executions&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;execution&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;id&amp;gt;&lt;span class=&quot;content&quot;&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;verify-checkstyle&lt;/span&gt;&lt;/span&gt;&amp;lt;/id&amp;gt;&lt;br /&gt;&amp;lt;phase&amp;gt;&lt;span class=&quot;content&quot;&gt;verify&lt;/span&gt;&amp;lt;/phase&amp;gt;&lt;br /&gt;&amp;lt;goals&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;goal&amp;gt;&lt;span class=&quot;content&quot;&gt;checkstyle&lt;/span&gt;&amp;lt;/goal&amp;gt;&lt;br /&gt;&lt;/div&gt;&amp;lt;/goals&amp;gt;&lt;br /&gt;&lt;/div&gt;&amp;lt;/execution&amp;gt;&lt;br /&gt;&lt;/div&gt;&amp;lt;/executions&amp;gt;&lt;br /&gt;&lt;/div&gt;&amp;lt;/plugin&amp;gt;&lt;br /&gt;...&lt;/div&gt;&lt;br /&gt;The snapshot shows us example of such existing configurations from our POM file.&lt;br /&gt;&lt;br /&gt;Then I disabled them in &lt;span style=&quot;font-style:italic;&quot;&gt;qbuild&lt;/span&gt; profile simply hooking to non existing build phase - &lt;span style=&quot;font-style:italic;&quot;&gt;noPhase&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;xml&quot;&gt;...&lt;br /&gt;&amp;lt;build&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;plugins&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;plugin&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;groupId&amp;gt;&lt;span class=&quot;content&quot;&gt;org.codehaus.mojo&lt;/span&gt;&amp;lt;/groupId&amp;gt;&lt;br /&gt;&amp;lt;artifactId&amp;gt;&lt;span class=&quot;content&quot;&gt;cobertura-maven-plugin&lt;/span&gt;&amp;lt;/artifactId&amp;gt;&lt;br /&gt;&amp;lt;executions&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;execution&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;id&amp;gt;&lt;span class=&quot;content&quot;&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;verify-coverage&lt;/span&gt;&lt;/span&gt;&amp;lt;/id&amp;gt;&lt;br /&gt;&amp;lt;phase&amp;gt;&lt;span class=&quot;content&quot;&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;noPhase&lt;/span&gt;&lt;/span&gt;&amp;lt;/phase&amp;gt;&lt;br /&gt;&lt;/div&gt;&amp;lt;/execution&amp;gt;&lt;br /&gt;&lt;/div&gt;&amp;lt;/executions&amp;gt;&lt;br /&gt;&lt;/div&gt;&amp;lt;/plugin&amp;gt;&lt;br /&gt;&amp;lt;plugin&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;groupId&amp;gt;&lt;span class=&quot;content&quot;&gt;org.apache.maven.plugins&lt;/span&gt;&amp;lt;/groupId&amp;gt;&lt;br /&gt;&amp;lt;artifactId&amp;gt;&lt;span class=&quot;content&quot;&gt;maven-checkstyle-plugin&lt;/span&gt;&amp;lt;/artifactId&amp;gt;&lt;br /&gt;&amp;lt;executions&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;execution&amp;gt;&lt;br /&gt;&lt;div class=&quot;child&quot;&gt;&amp;lt;id&amp;gt;&lt;span class=&quot;content&quot;&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;verify-checkstyle&lt;/span&gt;&lt;/span&gt;&amp;lt;/id&amp;gt;&lt;br /&gt;&amp;lt;phase&amp;gt;&lt;span class=&quot;content&quot;&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;noPhase&lt;/span&gt;&lt;/span&gt;&amp;lt;/phase&amp;gt;&lt;br /&gt;&lt;/div&gt;&amp;lt;/execution&amp;gt;&lt;br /&gt;&lt;/div&gt;&amp;lt;/executions&amp;gt;&lt;br /&gt;&lt;/div&gt;&amp;lt;/plugin&amp;gt;&lt;br /&gt;&lt;/div&gt;&amp;lt;/plugins&amp;gt;&lt;br /&gt;&lt;/div&gt;&amp;lt;/build&amp;gt;&lt;br /&gt;...&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The developers then were able to run build four times faster and without any unused build artifacts.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;cmd&quot;&gt;mvn clean install -Pqclean,qbuild&lt;/div&gt;&lt;br /&gt;They were all very satisfied with the result of the tuning and &lt;span style=&quot;font-weight:bold;&quot;&gt;the &quot;minus&quot; never appeared again in the further retrospectives !!!&lt;/span&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;div&gt;&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-9722020934797923&quot;;
/* Blog-Bosy-Feeds */
google_ad_slot = &quot;1800980789&quot;;
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bosy.dailydev.org/feeds/8312774378006739114/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4345824448663422013/8312774378006739114' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4345824448663422013/posts/default/8312774378006739114'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4345824448663422013/posts/default/8312774378006739114'/><link rel='alternate' type='text/html' href='http://bosy.dailydev.org/2009/02/speed-up-your-maven-build-four-times.html' title='Speed up Maven build'/><author><name>Roman B.</name><uri>http://www.blogger.com/profile/10191921864885167276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4345824448663422013.post-2643438510113814565</id><published>2007-08-01T20:40:00.002+02:00</published><updated>2008-10-28T19:52:22.842+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="coding tips"/><category scheme="http://www.blogger.com/atom/ns#" term="Eclipse"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="refactoring"/><title type='text'>Refactor singleton out of your code</title><content type='html'>&lt;span style=&quot;font-weight: bold;font-size:85%;&quot; &gt;There are a lot of posts about that the Singleton design pattern [&lt;a href=&quot;http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=http%3A%2F%2Fwww.amazon.com%2FDesign-Patterns-Object-Oriented-Addison-Wesley-Professional%2Fdp%2F0201633612%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1182152591%26sr%3D1-1&amp;amp;tag=dailydevelo-20&amp;linkCode=ur2&amp;amp;camp=1789&amp;creative=9325&quot;&gt;GoF&lt;/a&gt;&lt;img style=&quot;border: 0px none ; margin: 0px; padding: 0px ! important;&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=dailydevelo-20&amp;l=ur2&amp;amp;o=1&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; /&gt;] is not pattern but anti-pattern (eg. &lt;a href=&quot;http://accu.org/index.php/journals/337&quot;&gt;SINGLETON - the anti-pattern!&lt;/a&gt;). Some posts also proposes an alternatives for Singleton design pattern or solutions for already existing Singleton design pattern problem (eg. &lt;a href=&quot;http://tech.puredanger.com/2007/07/03/pattern-hate-singleton/&quot;&gt;Patterns I Hate #1: Singleton&lt;/a&gt;). But I didn&#39;t found any post which describes solution for big project with bunch of singleton class usage without big effort of rewriting many places by hand.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Because I was in situation that I should refactor a big project containing bunch of Singletons, I was thinking about some automatic way how to remove them. I found a solution using several refactorings. After bellow described sequence of steps you can replace Singleton design pattern by &lt;a href=&quot;http://www.martinfowler.com/eaaCatalog/registry.html&quot;&gt;Registry design pattern&lt;/a&gt; [&lt;a href=&quot;http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=http%3A%2F%2Fwww.amazon.com%2Fexec%2Fobidos%2FASIN%2F0321127420&amp;amp;amp;tag=dailydevelo-20&amp;linkCode=ur2&amp;amp;camp=1789&amp;creative=9325&quot;&gt;P of EAA&lt;/a&gt;&lt;img src=&quot;http://www.assoc-amazon.com/e/ir?t=dailydevelo-20&amp;amp;l=ur2&amp;o=1&quot; alt=&quot;&quot; style=&quot;border: 0px none ; margin: 0px; padding: 0px ! important;&quot; height=&quot;0&quot; width=&quot;0&quot; /&gt;] which solves all crucial problems of a Singleton, like testing possibility, singleton subclassing, ....&lt;br /&gt;&lt;br /&gt;Lets have simple singleton class which we want to refactor to access it&#39;s instance not as a singleton but using some registry.&lt;br /&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;keyword&quot;&gt;public class&lt;/span&gt; SingletonClass {&lt;br /&gt;&lt;dl&gt;&lt;dd&gt;&lt;span class=&quot;keyword&quot;&gt;private static final&lt;/span&gt; SingletonClass &lt;span class=&quot;field&quot;&gt;INSTANCE&lt;/span&gt; = &lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; SingletonClass();&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;public static&lt;/span&gt; SingletonClass getInstance() {&lt;br /&gt;&lt;dl&gt;&lt;dd&gt;&lt;span class=&quot;keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;field&quot;&gt;INSTANCE&lt;/span&gt;;&lt;/dd&gt;&lt;/dl&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;private&lt;/span&gt; SingletonClass() {&lt;br /&gt;&lt;dl&gt;&lt;dd&gt;&lt;span class=&quot;keyword&quot;&gt;super&lt;/span&gt;();&lt;/dd&gt;&lt;/dl&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;public void&lt;/span&gt; voidMethod(String param) {&lt;br /&gt;&lt;dl&gt;&lt;dd&gt;System.out.println(&lt;span class=&quot;string&quot;&gt;&quot;Doing something in method returning void&quot;&lt;/span&gt;);&lt;/dd&gt;&lt;/dl&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;public&lt;/span&gt; Object objectMethod(String param) {&lt;br /&gt;&lt;dl&gt;&lt;dd&gt;System.out.println(&quot;Doing something in method returning Object&quot;);&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;return new&lt;/span&gt; String(&lt;span class=&quot;string&quot;&gt;&quot;This is an String&quot;&lt;/span&gt;);&lt;/dd&gt;&lt;/dl&gt;}&lt;/dd&gt;&lt;/dl&gt;}&lt;/div&gt;&lt;br /&gt;and also lets have very simple client class which access the singleton&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;keyword&quot;&gt;public class&lt;/span&gt; Client {&lt;br /&gt;&lt;dl&gt;&lt;dd&gt;&lt;span class=&quot;keyword&quot;&gt;public void&lt;/span&gt; clientMethod() {&lt;br /&gt;&lt;dl&gt;&lt;dd&gt;SingletonClass.getInstance().voidMethod(&lt;span class=&quot;string&quot;&gt;&quot;param&quot;&lt;/span&gt;);&lt;br /&gt;Object object = SingletonClass.getInstance().objectMethod(&lt;span class=&quot;string&quot;&gt;&quot;param&quot;&lt;/span&gt;);&lt;/dd&gt;&lt;/dl&gt;}&lt;/dd&gt;&lt;/dl&gt;}&lt;/div&gt;&lt;ul&gt;&lt;li&gt;At the first I create simple interface for Registry with two simple methods - getter and setter for instance of class which is currently implemented as singleton (SingletonClass in my example). There are also other variants of Registry implementation. For example you can have one generic methods getService and setService with some selector as a parameter (String ID, service class, ...). But I choosed the simplest one.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;keyword&quot;&gt;public interface&lt;/span&gt; ISingletonRegistry {&lt;br /&gt;&lt;dl&gt;&lt;dd&gt;SingletonClass getSingletonClass();&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;void&lt;/span&gt; setSingletonClass(SingletonClass singleton);&lt;/dd&gt;&lt;/dl&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Make SingletonClass&#39;s constructor public&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Then implement the interface as a simplest Registry design pattern implementation - SingletonRegistry.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;keyword&quot;&gt;public class&lt;/span&gt; SingletonRegistry &lt;span class=&quot;keyword&quot;&gt;implements&lt;/span&gt; ISingletonRegistry {&lt;br /&gt;&lt;dl&gt;&lt;dd&gt;&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;private static final&lt;/span&gt; SingletonRegistry &lt;span class=&quot;field&quot;&gt;INSTANCE&lt;/span&gt; = &lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; SingletonRegistry();&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;private&lt;/span&gt; SingletonClass &lt;span class=&quot;field&quot;&gt;singleton&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;public static&lt;/span&gt; ISingletonRegistry getInstance() {&lt;br /&gt;&lt;dl&gt;&lt;dd&gt;&lt;span class=&quot;keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;field&quot;&gt;INSTANCE&lt;/span&gt;;&lt;/dd&gt;&lt;/dl&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;private&lt;/span&gt; SingletonRegistry() {&lt;br /&gt;&lt;dl&gt;&lt;dd&gt;&lt;span class=&quot;comment&quot;&gt;//this is the reason why the constructor should be public&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;field&quot;&gt;singleton&lt;/span&gt; = &lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; SingletonClass();&lt;/dd&gt;&lt;/dl&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;public&lt;/span&gt; SingletonClass getSingletonClass() {&lt;br /&gt;&lt;dl&gt;&lt;dd&gt;&lt;span class=&quot;keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;field&quot;&gt;singleton&lt;/span&gt;;&lt;/dd&gt;&lt;/dl&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;public void&lt;/span&gt; setSingletonClass(SingletonClass singleton) {&lt;br /&gt;&lt;dl&gt;&lt;dd&gt;&lt;span class=&quot;keyword&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;field&quot;&gt;singleton&lt;/span&gt; = singleton;&lt;/dd&gt;&lt;/dl&gt;}&lt;/dd&gt;&lt;/dl&gt;}&lt;/div&gt;&lt;br /&gt;You can see that I implemented it as singleton (of course using practise described in one of my previous posts - &lt;a href=&quot;http://dailydevelopment.blogspot.com/2007/06/singleton-pattern-implementation-in-4.html&quot;&gt;Singleton pattern implementation in 4 steps&lt;/a&gt; :-). I know that a lot of readers will have animadversions that I am creating new singleton when I want to remove other singletons. But realize that singleton is not evil every time. Also &lt;a href=&quot;http://java.sun.com/blueprints/corej2eepatterns/Patterns/ServiceLocator.html&quot;&gt;Service Locator design pattern&lt;/a&gt; uses singleton to access ServiceLocator instance.&lt;br /&gt;You can also see that constructor of the class initializes reference to SingletonClass instance. Of course this is just possibility. You can use some mechanism of configuration of the singleton instances. But note that it should be performed before you use SingletonRegistry by some client for the first time by. Anyway this implicit setup can stay here because you are able to set different instance of SingletonClass using setSingletonClass method.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Change getInstance method of SingletonClass to get instance from SingletonRegistry.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;keyword&quot;&gt;public static&lt;/span&gt; SingletonClass getInstance() {&lt;br /&gt;&lt;dl&gt;&lt;dd&gt;&lt;span class=&quot;keyword&quot;&gt;return&lt;/span&gt; SingletonRegistry.getInstance().getSingletonClass();&lt;/dd&gt;&lt;/dl&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Over getInstance method of SingletonClass perform Inline&lt;span style=&quot;font-style: italic;&quot;&gt;...&lt;/span&gt; refactoring (&lt;span class=&quot;shortcut&quot;&gt;Alt+Shift+I&lt;/span&gt;), mark &#39;Delete method declaration&#39; chekbox and click OK. The method getInstance from SingletonClass disappears and all it&#39;s client classes uses SingletonRegistry to access SingletonClass.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;keyword&quot;&gt;public class&lt;/span&gt; Client {&lt;br /&gt;&lt;dl&gt;&lt;dd&gt;&lt;span class=&quot;keyword&quot;&gt;public void&lt;/span&gt; clientMethod() {&lt;br /&gt;&lt;dl&gt;&lt;dd&gt;SingletonRegistry.getInstance() .getSingletonClass().voidMethod(&lt;span class=&quot;string&quot;&gt;&quot;param&quot;&lt;/span&gt;);&lt;br /&gt;Object object = SingletonRegistry.getInstance() .getSingletonClass().objectMethod(&lt;span class=&quot;string&quot;&gt;&quot;param&quot;&lt;/span&gt;);&lt;/dd&gt;&lt;/dl&gt;}&lt;/dd&gt;&lt;/dl&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Delete INSTANCE constant from SingletonClass class.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;As a cherry on top of a cake you can Extract Interface (&lt;span class=&quot;shortcut&quot;&gt;Alt+Shift+T, E&lt;/span&gt;) from SingletonClass. Write just new interface name, select all methods from SingletonClass which you can extract into new interface and press OK. All references to SingletonClass will be refactored to references to your newly created interface.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;And that is all. Now you have SingletonClass with totally same functionality but you are able to mock it, extend or replace by different implementation setting up your instance of SingletonClass to SingletonRegistry.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;References:&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li style=&quot;font-size: 85%; font-weight: bold;&quot;&gt;&lt;a href=&quot;http://www.martinfowler.com/eaaCatalog/registry.html&quot;&gt;Registry pattern&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;font-size: 85%; font-weight: bold;&quot;&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Singleton_pattern&quot;&gt;Singleton design pattern&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;font-size: 85%; font-weight: bold;&quot;&gt;&lt;a href=&quot;http://java.sun.com/blueprints/corej2eepatterns/Patterns/ServiceLocator.html&quot;&gt;Service Locator design pattern&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;div&gt;&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-9722020934797923&quot;;
/* Blog-Bosy-Feeds */
google_ad_slot = &quot;1800980789&quot;;
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bosy.dailydev.org/feeds/2643438510113814565/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4345824448663422013/2643438510113814565' title='13 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4345824448663422013/posts/default/2643438510113814565'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4345824448663422013/posts/default/2643438510113814565'/><link rel='alternate' type='text/html' href='http://bosy.dailydev.org/2007/08/refactor-singleton-out-of-your-code.html' title='Refactor singleton out of your code'/><author><name>Roman B.</name><uri>http://www.blogger.com/profile/10191921864885167276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4345824448663422013.post-7609394726924517053</id><published>2007-07-02T19:05:00.006+02:00</published><updated>2017-05-30T13:22:57.923+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="application"/><category scheme="http://www.blogger.com/atom/ns#" term="fun"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><title type='text'>My first real Java application</title><content type='html'>I just found very funny Java application in my archive. It was year 1999 and I was studying college in Ostrava. We had strange theme called Java Technologies. Following applet was my semestral project for the theme. It is very simple, multi threaded (!!!), simulation of cross way. A colored squares are cars and yellow squares in their corners are flashers. The cars follows traffic lights and right-hand rule. Look and enjoy :-)&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;width: 100%; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;applet archive=&quot;https://www.dropbox.com/s/kne8lq2tbnudnvx/crossway.jar?dl=0&quot; code=&quot;dd.crossway/Crossway.class&quot; height=&quot;300&quot; width=&quot;300&quot;&gt;&lt;br /&gt;
&lt;/applet&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Do you want sources? Download &lt;a style=&quot;font-weight: bold;&quot; href=&quot;https://www.dropbox.com/s/xnncjn31obs609l/crossway.zip?dl=0&quot;&gt;crossway.zip&lt;/a&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;div&gt;&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-9722020934797923&quot;;
/* Blog-Bosy-Feeds */
google_ad_slot = &quot;1800980789&quot;;
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bosy.dailydev.org/feeds/7609394726924517053/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4345824448663422013/7609394726924517053' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4345824448663422013/posts/default/7609394726924517053'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4345824448663422013/posts/default/7609394726924517053'/><link rel='alternate' type='text/html' href='http://bosy.dailydev.org/2007/07/my-first-real-java-application.html' title='My first real Java application'/><author><name>Roman B.</name><uri>http://www.blogger.com/profile/10191921864885167276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4345824448663422013.post-7747560400804403866</id><published>2007-07-02T10:52:00.000+02:00</published><updated>2007-07-02T17:26:54.265+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bookmarking"/><category scheme="http://www.blogger.com/atom/ns#" term="environment"/><category scheme="http://www.blogger.com/atom/ns#" term="team"/><title type='text'>What I am missing on del.icio.us</title><content type='html'>As member of a team I was looking for some solution which will enable us to share bookmarks across the team. Because I have some good experiences with &lt;a style=&quot;font-weight: bold;&quot; href=&quot;http://del.icio.us/&quot;&gt;del.icio.us&lt;/a&gt; bookmark manager and it also fulfil basic conditions, my focus was clear from the beginning.&lt;br /&gt;&lt;br /&gt;The basic conditions were:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;bookmarks should be shared among all team members&lt;/li&gt;&lt;li&gt;because the members are traveling and then they are out of corporate network we need access to bookmarks from anywhere&lt;/li&gt;&lt;li&gt;posting and using bookmark should be as simple as possible&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;Then I identified additional conditions:&lt;br /&gt;&lt;ol start=&quot;4&quot;&gt;&lt;li&gt;some members uses IE, some members uses Mozilla&lt;/li&gt;&lt;li&gt;at least some members of team (eg. me :-) has it&#39;s own personal account on &lt;span style=&quot;font-weight: bold;&quot;&gt;del.icio.us&lt;/span&gt; and they want to use bookmarks from both of them at a time.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;My idea was that every member will have it&#39;s own account and will be logged in using browser extension. There will be also team specific account (TA) and every member will add it into it&#39;s network. At the beginning I thought that it will enable me to see my and TA&#39;s bookmarks on one heap and I will also be able to add &lt;span style=&quot;font-style: italic;&quot;&gt;for:ta&lt;/span&gt; tag from a suggestions when posting new team bookmark. But:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;network member&#39;s bookmarks are not merged between user&#39;s bookmarks (I mean merged just for view)&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;for:ta&lt;/span&gt; tag suggestion is present, but it adds bookmarks just into &lt;span style=&quot;font-style: italic;&quot;&gt;&quot;links for you&quot;&lt;/span&gt; section of TA (BTW at the moment it is impossible to remove proposed bookmark - see &lt;a href=&quot;http://del.icio.us/help/faq#Can_I_delete_items_from_links_fo&quot;&gt;del.icio.us FAQ&lt;/a&gt;)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Those two problems cause that:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;we can&#39;t use personal and TA account together with browser extension&lt;/li&gt;&lt;li&gt;somebody should be responsible for accepting proposed bookmarks of TA from &lt;span style=&quot;font-style: italic;&quot;&gt;&quot;links for you&quot;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;But I found workarounds (just for Mozilla which implements &lt;a href=&quot;http://mozilla.gunnars.net/firefox_bookmarks_tutorial.html#live_bookmarks&quot;&gt;Live Bookmarks&lt;/a&gt;). Both bookmark sets (TA&#39;s bookmarks and TA&#39;s &lt;span style=&quot;font-style: italic;&quot;&gt;&quot;links for you&quot;&lt;/span&gt; bookmarks) provides RSS feeds. So every member will have two Live Bookmarks through which he can access both groups of shared bookmarks. But the solution still have several imperfections:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;you cant use browser extension to access team bookmarks&lt;br /&gt;&lt;/li&gt;&lt;li&gt;you can&#39;t search bookmarks by tags (but you can create more Live Bookmarks for each or some tags)&lt;/li&gt;&lt;li&gt;when somebody save bookmarks from &lt;span style=&quot;font-style: italic;&quot;&gt;&quot;links for you&quot;&lt;/span&gt; to main group the bookmark is present in both groups&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Maybe we are trying to get pears from apple tree. I also know that &lt;span style=&quot;font-weight: bold;&quot;&gt;del.icio.us&lt;/span&gt; want to stay as simple as possible and they do it very well, but still I have some proposals to &lt;span style=&quot;font-weight: bold;&quot;&gt;del.icio.us&lt;/span&gt; team:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;improve &lt;span style=&quot;font-style: italic;&quot;&gt;&quot;links for you&quot;&lt;/span&gt; functionality&lt;/li&gt;&lt;ul&gt;&lt;li&gt;user can define list of trusted users and their proposed bookmarks will be added directly (with some flag) into &lt;span style=&quot;font-style: italic;&quot;&gt;&quot;my bookmarks&quot;&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;provide possibility to delete bookmarks from &lt;span style=&quot;font-style: italic;&quot;&gt;&quot;links from you&quot;&lt;/span&gt; group (in progress - see &lt;a href=&quot;http://del.icio.us/help/faq#Can_I_delete_items_from_links_fo&quot;&gt;del.icio.us FAQ&lt;/a&gt;)&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;improve &lt;span style=&quot;font-style: italic;&quot;&gt;&quot;network&quot;&lt;/span&gt; functionality&lt;/li&gt;&lt;ul&gt;&lt;li&gt;provide possiblity to configure you network member to have his bookmarks merged (just for view) between your bookmarks&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;provide RSS feeds containing users tags&lt;/li&gt;&lt;/ul&gt;Anyway, at the moment we use it with workarounds and we are happy at least with this solutions, but it can be better.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;div&gt;&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-9722020934797923&quot;;
/* Blog-Bosy-Feeds */
google_ad_slot = &quot;1800980789&quot;;
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bosy.dailydev.org/feeds/7747560400804403866/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4345824448663422013/7747560400804403866' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4345824448663422013/posts/default/7747560400804403866'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4345824448663422013/posts/default/7747560400804403866'/><link rel='alternate' type='text/html' href='http://bosy.dailydev.org/2007/06/what-i-am-missing-in-delicious.html' title='What I am missing on del.icio.us'/><author><name>Roman B.</name><uri>http://www.blogger.com/profile/10191921864885167276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4345824448663422013.post-8706216904275050590</id><published>2007-06-14T20:00:00.000+02:00</published><updated>2007-06-18T16:11:21.126+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="architecture"/><category scheme="http://www.blogger.com/atom/ns#" term="design patterns"/><category scheme="http://www.blogger.com/atom/ns#" term="intercepting filter"/><category scheme="http://www.blogger.com/atom/ns#" term="J2EE"/><title type='text'>Intercepting Filter Design Pattern</title><content type='html'>&lt;span style=&quot;FONT-WEIGHT: bold;font-size:85%;&quot; &gt;Intercepting Filter is classified as an enterprise or J2EE design pattern. Intercepting Filter design pattern is typically used in cases where some messages should be processed but the target processing should be wrapped into chain of arbitrary pre/post processings as are authorization checks, message resources transformations (eg. translation, escaping), ...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Intercepting Filter design pattern is built from five basic components:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;FilterManager&lt;/li&gt;&lt;li&gt;FilterChain&lt;/li&gt;&lt;li&gt;IFilter interface&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Context&lt;br /&gt;&lt;/li&gt;&lt;li&gt;ITarget interface&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8BqSro4w8XH0sh1aCodURvA8eFSknGRj8DXzCh9V2u8fhX6YNNQ3lbI9N2ll-fxQs-YhB-uJCIKmlrG4u_0cMPdCqelkVhD78bXiyGN_KRckMMcbANIGvpGsKuDw1ixC387llKp-Bb-a2/s1600-h/InterceptingFilter_classes.PNG&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5075970120454823906&quot; style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: pointer; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8BqSro4w8XH0sh1aCodURvA8eFSknGRj8DXzCh9V2u8fhX6YNNQ3lbI9N2ll-fxQs-YhB-uJCIKmlrG4u_0cMPdCqelkVhD78bXiyGN_KRckMMcbANIGvpGsKuDw1ixC387llKp-Bb-a2/s400/InterceptingFilter_classes.PNG&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style=&quot;FONT-WEIGHT: bold;font-size:85%;&quot; &gt;FilterManager&lt;/span&gt; - &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;FilterManager&lt;/span&gt; class is a boundary class of Intercepting Filter design pattern. It means that a client uses it as an interface to process some target operation (represented by &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;ITarget&lt;/span&gt; interface) in a specific context (represented by abstract interface &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Context&lt;/span&gt;). &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;FilterManager&lt;/span&gt; is then typically responsible for &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;FilterChain&lt;/span&gt; creation, it&#39;s setup (concrete filter set configuration, target propagation, ...) and finally it&#39;s execution.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;FONT-WEIGHT: bold;font-size:85%;&quot; &gt;FilterChain&lt;/span&gt; - &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;FilterChain&lt;/span&gt; class is basicaly data object carrying list of filters and the target, with just very simple logic of filter queue.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;FONT-WEIGHT: bold;font-size:85%;&quot; &gt;IFilter&lt;/span&gt; - &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;IFilter&lt;/span&gt; interface has just one method. The method is typically implemented as captured on following diagram. It makes some pre processing, and if everything is OK than it calls &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;FilterChain&lt;/span&gt; to process to following filter.&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiVCB5K2x3M7h9-bO_bKduNpKeUT3kRbjNaI0yvraJy5nloFAzdDLzVsoeSu9O43f_E1duhrkiZW_xbxV0ge-RPWQPGRbQHtlQR3w4YAnZP9OGF3nwUVIaunkLFqgU7WSVgatfOML5K_6q/s1600-h/InterceptingFilter_basicFlow.PNG&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5075976846373609458&quot; style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: pointer; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiVCB5K2x3M7h9-bO_bKduNpKeUT3kRbjNaI0yvraJy5nloFAzdDLzVsoeSu9O43f_E1duhrkiZW_xbxV0ge-RPWQPGRbQHtlQR3w4YAnZP9OGF3nwUVIaunkLFqgU7WSVgatfOML5K_6q/s400/InterceptingFilter_basicFlow.PNG&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;If something is wrong (some data are wrong or missing in Context) then it can return or throw exception.&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyJHhnoKiFDsoFdCM-4EiIDFWJNSrzr84SAbqQ3dMxS-YjrQBtG2tx4oGnt4Ou8JmhdfdlaPTqyYLxJjB3GWQnn4wn2j7XMeItEG2x0-LshaNqSntQPjrTCdigOzvZ4jnEAqTZSDJNOPVJ/s1600-h/InterceptingFilter_exceptionalFlow.PNG&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5075977104071647234&quot; style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: pointer; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyJHhnoKiFDsoFdCM-4EiIDFWJNSrzr84SAbqQ3dMxS-YjrQBtG2tx4oGnt4Ou8JmhdfdlaPTqyYLxJjB3GWQnn4wn2j7XMeItEG2x0-LshaNqSntQPjrTCdigOzvZ4jnEAqTZSDJNOPVJ/s400/InterceptingFilter_exceptionalFlow.PNG&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;When the target is reached through chain of filters, it is processed, and the thread is returning back same way, so it can make some post processing in every filter, during which it can also make some changes to &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Context&lt;/span&gt; (eg. response translation, escaping, ...).&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;FONT-WEIGHT: bold;font-size:85%;&quot; &gt;ITarget&lt;/span&gt; - &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;ITarget&lt;/span&gt; interface should be implemented as message receiver or it&#39;s wrapper.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;FONT-WEIGHT: bold;font-size:85%;&quot; &gt;Context&lt;/span&gt; - &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Context&lt;/span&gt; class in this presentation of Intercepting Filter design pattern should be considered as &lt;span style=&quot;FONT-WEIGHT: bold&quot;&gt;very abstract&lt;/span&gt;. It means that it can be totally different type of class or it can be set of classes or it can be some Map, etc. For example it can be &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;ServletRequest&lt;/span&gt; together with &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;ServletResponse&lt;/span&gt; when we are talking about Intercepting Filter design pattern implementation defined by Sun - &lt;a href=&quot;http://java.sun.com/blueprints/corej2eepatterns/Patterns/InterceptingFilter.html&quot;&gt;Core J2EE Patterns - Intercepting Filter&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Implementation of Intercepting Filter design pattern is pretty simple. The most complex component can be &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;FilterManager&lt;/span&gt; which can implement some sophisticated way of configuration which defines mapping filters to context and their configuration. But whenever it is implemented it is very simple to extend message processing by new features or change its behavior.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;FONT-WEIGHT: bold&quot;&gt;Related patterns:&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li style=&quot;FONT-WEIGHT: bold&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Decorator&lt;/span&gt; [&lt;a href=&quot;http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=http%3A%2F%2Fwww.amazon.com%2FDesign-Patterns-Object-Oriented-Addison-Wesley-Professional%2Fdp%2F0201633612%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1182152591%26sr%3D1-1&amp;amp;amp;amp;amp;amp;amp;amp;tag=dailydevelo-20&amp;linkCode=ur2&amp;amp;camp=1789&amp;creative=9325&quot;&gt;GoF&lt;/a&gt;&lt;img style=&quot;BORDER-RIGHT: 0px; PADDING-RIGHT: 0px! important; BORDER-TOP: 0px; PADDING-LEFT: 0px! important; PADDING-BOTTOM: 0px! important; MARGIN: 0px; BORDER-LEFT: 0px; PADDING-TOP: 0px! important; BORDER-BOTTOM: 0px&quot; height=&quot;0&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=dailydevelo-20&amp;l=ur2&amp;amp;o=1&quot; width=&quot;0&quot; border=&quot;0&quot; /&gt;]&lt;/li&gt;&lt;ul&gt;&lt;li style=&quot;FONT-WEIGHT: normal&quot;&gt;Does not have &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;FilterChain&lt;/span&gt;&lt;span style=&quot;FONT-STYLE: italic&quot;&gt; &lt;/span&gt;- the order of filters is defined wrapping one filter into another.&lt;/li&gt;&lt;/ul&gt;&lt;li style=&quot;FONT-WEIGHT: bold&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Template Method&lt;/span&gt; [&lt;a href=&quot;http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=http%3A%2F%2Fwww.amazon.com%2FDesign-Patterns-Object-Oriented-Addison-Wesley-Professional%2Fdp%2F0201633612%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1182152591%26sr%3D1-1&amp;amp;amp;amp;amp;amp;amp;amp;tag=dailydevelo-20&amp;linkCode=ur2&amp;amp;camp=1789&amp;creative=9325&quot;&gt;GoF&lt;/a&gt;&lt;img style=&quot;BORDER-RIGHT: 0px; PADDING-RIGHT: 0px! important; BORDER-TOP: 0px; PADDING-LEFT: 0px! important; PADDING-BOTTOM: 0px! important; MARGIN: 0px; BORDER-LEFT: 0px; PADDING-TOP: 0px! important; BORDER-BOTTOM: 0px&quot; height=&quot;0&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=dailydevelo-20&amp;l=ur2&amp;amp;o=1&quot; width=&quot;0&quot; border=&quot;0&quot; /&gt;]&lt;/li&gt;&lt;ul&gt;&lt;li style=&quot;FONT-WEIGHT: normal&quot;&gt;Very simple version of Intercepting Filter design pattern implementing &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Filter Chain &lt;/span&gt;(template method) and &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;IFilter &lt;/span&gt;implementations (methods called from template method) in one class.&lt;/li&gt;&lt;/ul&gt;&lt;li style=&quot;FONT-WEIGHT: bold&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Chain of Responsibility&lt;/span&gt; [&lt;a href=&quot;http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=http%3A%2F%2Fwww.amazon.com%2FDesign-Patterns-Object-Oriented-Addison-Wesley-Professional%2Fdp%2F0201633612%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1182152591%26sr%3D1-1&amp;amp;amp;amp;amp;amp;amp;amp;tag=dailydevelo-20&amp;linkCode=ur2&amp;amp;camp=1789&amp;creative=9325&quot;&gt;GoF&lt;/a&gt;&lt;img style=&quot;BORDER-RIGHT: 0px; PADDING-RIGHT: 0px! important; BORDER-TOP: 0px; PADDING-LEFT: 0px! important; PADDING-BOTTOM: 0px! important; MARGIN: 0px; BORDER-LEFT: 0px; PADDING-TOP: 0px! important; BORDER-BOTTOM: 0px&quot; height=&quot;0&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=dailydevelo-20&amp;l=ur2&amp;amp;o=1&quot; width=&quot;0&quot; border=&quot;0&quot; /&gt;]&lt;/li&gt;&lt;ul&gt;&lt;li style=&quot;FONT-WEIGHT: normal&quot;&gt;Does not have &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;FilterChain&lt;/span&gt;&lt;span style=&quot;FONT-STYLE: italic&quot;&gt; &lt;/span&gt;- the order of &quot;interceptors&quot; is defined as chain of successors.&lt;/li&gt;&lt;/ul&gt;&lt;li style=&quot;FONT-WEIGHT: bold&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;a href=&quot;http://dailydevelopment.blogspot.com/2007/04/interceptor-design-pattern.html&quot;&gt;Interceptor&lt;/a&gt;&lt;/span&gt; [&lt;a href=&quot;http://www.blogger.com/%20%20%20http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=http%3A%2F%2Fwww.amazon.com%2FPattern-Oriented-Software-Architecture-Concurrent-Networked%2Fdp%2F0471606952%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1181656011%26sr%3D8-1&amp;amp;amp;amp;amp;amp;amp;amp;amp;tag=dailydevelo-20&amp;linkCode=ur2&amp;amp;camp=1789&amp;creative=9325%20&quot;&gt;POSA2&lt;/a&gt;&lt;img style=&quot;BORDER-RIGHT: 0px; PADDING-RIGHT: 0px! important; BORDER-TOP: 0px; PADDING-LEFT: 0px! important; PADDING-BOTTOM: 0px! important; MARGIN: 0px; BORDER-LEFT: 0px; PADDING-TOP: 0px! important; BORDER-BOTTOM: 0px&quot; height=&quot;0&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=dailydevelo-20&amp;l=ur2&amp;amp;o=1&quot; width=&quot;0&quot; border=&quot;0&quot; /&gt;]&lt;/li&gt;&lt;ul&gt;&lt;li style=&quot;FONT-WEIGHT: normal&quot;&gt;Similar also to Chain of Responsibility but the chain of successors is not &quot;hard coded&quot; but propagated to &quot;interceptor&quot; as parameter of the method call.&lt;/li&gt;&lt;/ul&gt;&lt;li style=&quot;FONT-WEIGHT: bold&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Pipes and Filters&lt;/span&gt; [&lt;a href=&quot;http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=http%3A%2F%2Fwww.amazon.com%2Fgp%2Freader%2F0471958697%3Fie%3DUTF8%26p%3DS008%23reader-link&amp;amp;amp;amp;amp;amp;amp;amp;amp;tag=dailydevelo-20&amp;linkCode=ur2&amp;amp;camp=1789&amp;creative=9325&quot;&gt;POSA1&lt;/a&gt;&lt;img style=&quot;BORDER-RIGHT: 0px; PADDING-RIGHT: 0px! important; BORDER-TOP: 0px; PADDING-LEFT: 0px! important; PADDING-BOTTOM: 0px! important; MARGIN: 0px; BORDER-LEFT: 0px; PADDING-TOP: 0px! important; BORDER-BOTTOM: 0px&quot; height=&quot;0&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=dailydevelo-20&amp;l=ur2&amp;amp;o=1&quot; width=&quot;0&quot; border=&quot;0&quot; /&gt;]&lt;/li&gt;&lt;ul&gt;&lt;li style=&quot;FONT-WEIGHT: normal&quot;&gt;The Pipes and Filters design pattern is oriented basically for stream related use cases. It also doesn&#39;t provide implicit possibility of post processing.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;span style=&quot;FONT-WEIGHT: bold&quot;&gt;References:&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li style=&quot;font-size:85%;font-weight: bold;&quot;&gt;&lt;a href=&quot;http://java.sun.com/blueprints/corej2eepatterns/Patterns/InterceptingFilter.html&quot;&gt;Core J2EE Patterns - Intercepting Filter&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;font-size:85%;font-weight: bold;&quot;&gt;&lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/ms978727.aspx&quot;&gt;MSDN - Intercepting Filter&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;div&gt;&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-9722020934797923&quot;;
/* Blog-Bosy-Feeds */
google_ad_slot = &quot;1800980789&quot;;
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bosy.dailydev.org/feeds/8706216904275050590/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4345824448663422013/8706216904275050590' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4345824448663422013/posts/default/8706216904275050590'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4345824448663422013/posts/default/8706216904275050590'/><link rel='alternate' type='text/html' href='http://bosy.dailydev.org/2007/04/intercepting-filter-design-pattern.html' title='Intercepting Filter Design Pattern'/><author><name>Roman B.</name><uri>http://www.blogger.com/profile/10191921864885167276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8BqSro4w8XH0sh1aCodURvA8eFSknGRj8DXzCh9V2u8fhX6YNNQ3lbI9N2ll-fxQs-YhB-uJCIKmlrG4u_0cMPdCqelkVhD78bXiyGN_KRckMMcbANIGvpGsKuDw1ixC387llKp-Bb-a2/s72-c/InterceptingFilter_classes.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4345824448663422013.post-3114380879487336716</id><published>2007-05-30T15:41:00.001+02:00</published><updated>2007-07-04T08:19:41.717+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="coding tips"/><category scheme="http://www.blogger.com/atom/ns#" term="Eclipse"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="refactoring"/><title type='text'>Singleton pattern implementation in 4 steps</title><content type='html'>&lt;span style=&quot;font-weight: bold;font-size:85%;&quot; &gt;The article describes very simple, fast and efficient way how to create class implementing Singleton design pattern [&lt;a href=&quot;http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=http%3A%2F%2Fwww.amazon.com%2FDesign-Patterns-Object-Oriented-Addison-Wesley-Professional%2Fdp%2F0201633612%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1181741572%26sr%3D8-1&amp;amp;amp;amp;tag=dailydevelo-20&amp;linkCode=ur2&amp;amp;camp=1789&amp;creative=9325&quot;&gt;GoF&lt;/a&gt;&lt;img src=&quot;http://www.assoc-amazon.com/e/ir?t=dailydevelo-20&amp;amp;amp;amp;amp;l=ur2&amp;o=1&quot; alt=&quot;&quot; style=&quot;border: 0pt none  ! important; margin: 0px ! important; padding: 0px ! important;&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; /&gt;]. Everything is done in 4 steps using standard features of Eclipse IDE (refactoring and source code manipulation). But it is of course applicable for every IDE providing similar refactoring functionality.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Steps:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Create new empty &#39;&lt;span&gt;SingletonClass&lt;/span&gt;&#39; class - use &lt;span style=&quot;font-style: italic;&quot;&gt;New &gt; Class&lt;/span&gt; action from popup menu over package or &lt;span style=&quot;font-style: italic; font-weight: bold;&quot;&gt;Ctrl+N&lt;/span&gt; shortcut. In the dialog just ensure that the source folder and project are specified and define the name of new class. Press &lt;span style=&quot;font-style: italic; font-weight: bold;&quot;&gt;Enter&lt;/span&gt; or click &lt;span style=&quot;font-style: italic;&quot;&gt;OK&lt;/span&gt;.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkirYxIJPACQfNIWSqesYxil1ok4R_MZZi-NbTfLuH3fH-m0wpbpv4M0F3LiEH-fECVXRvOCndh9EKisu9izUw3_0W3Nimc-VeToP5dPdDE7SbhlB-amp058iDgu-_jyaeZ9NIc9LOt1_R/s1600-h/singleton_02_EmptyClass.PNG&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkirYxIJPACQfNIWSqesYxil1ok4R_MZZi-NbTfLuH3fH-m0wpbpv4M0F3LiEH-fECVXRvOCndh9EKisu9izUw3_0W3Nimc-VeToP5dPdDE7SbhlB-amp058iDgu-_jyaeZ9NIc9LOt1_R/s400/singleton_02_EmptyClass.PNG&quot; alt=&quot;New Class Created&quot; id=&quot;BLOGGER_PHOTO_ID_5070363364873048050&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;From the body of the class invoke &lt;span style=&quot;font-style: italic;&quot;&gt;Source &gt; Generate Constructors from Superclass...&lt;/span&gt; action, of course using &lt;span style=&quot;font-style: italic; font-weight: bold;&quot;&gt;Alt+Shift+S, C&lt;/span&gt; shortcut. In the following diaglog just press &lt;span style=&quot;font-style: italic; font-weight: bold;&quot;&gt;Enter&lt;/span&gt; or click &lt;span style=&quot;font-style: italic;&quot;&gt;OK&lt;/span&gt;. (This step can be done together with prvious step checking &#39;Constructors from superclass&#39; option in the &#39;New Java Class&#39; dialog).&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjmi9bEJwH5WvyZzThpIc6d_kD77K5mIDOSr_RCw7VEbuwDJuo8hKmY3bDilF4O1JSBhjrssB3utLwsIqsnR3VFp73uNFPAaloj9uXRbQzVbV7kUKF95Bhejemibeprv7YKZKKFo-t9o-z/s1600-h/singleton_02_Constructor.PNG&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjmi9bEJwH5WvyZzThpIc6d_kD77K5mIDOSr_RCw7VEbuwDJuo8hKmY3bDilF4O1JSBhjrssB3utLwsIqsnR3VFp73uNFPAaloj9uXRbQzVbV7kUKF95Bhejemibeprv7YKZKKFo-t9o-z/s400/singleton_02_Constructor.PNG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5070368042092433410&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;From the constructor signature definition (constructor name) invoke &lt;span style=&quot;font-style: italic;&quot;&gt;Refactor &gt; Introduce Factory...&lt;/span&gt; action (using &lt;span style=&quot;font-style: italic; font-weight: bold;&quot;&gt;Alt+Shift+T, O&lt;/span&gt; shortcut). In an &#39;Introduce Factory&#39; dialog change &#39;Factory method name&#39; value to the name of singleton access method (eg. getInstance). Press &lt;span style=&quot;font-style: italic; font-weight: bold;&quot;&gt;Enter&lt;/span&gt; or click &lt;span style=&quot;font-style: italic;&quot;&gt;OK&lt;/span&gt;.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9mwIxxxVKlIRQhJyxIcKUMukZlixVhyphenhyphenFFCRnUIUZCgLL42yYCP4T55a8FIkms2goCI4WNvIZzEK10SF5quFh4JeGb-5NHnXonAv2DaMpSKkE2JG_KHDSiItOhyCSI_nLD-51DDHNt_Jrv/s1600-h/singleton_03_factoryMethod.PNG&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9mwIxxxVKlIRQhJyxIcKUMukZlixVhyphenhyphenFFCRnUIUZCgLL42yYCP4T55a8FIkms2goCI4WNvIZzEK10SF5quFh4JeGb-5NHnXonAv2DaMpSKkE2JG_KHDSiItOhyCSI_nLD-51DDHNt_Jrv/s400/singleton_03_factoryMethod.PNG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5070372100836528146&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Select &#39;&lt;span style=&quot;font-weight: bold;&quot;&gt;new SingletonClass()&lt;/span&gt;&#39; from &#39;&lt;span style=&quot;font-weight: bold;&quot;&gt;getInstance()&lt;/span&gt;&#39; method and invoke &lt;span style=&quot;font-style: italic;&quot;&gt;Refactor &gt; Extract Constant...&lt;/span&gt; action (&lt;span style=&quot;font-style: italic; font-weight: bold;&quot;&gt;Alt+ Shift + T, A&lt;/span&gt;).&lt;/li&gt;&lt;/ul&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmNJ6LerFUIaW0wF5IOrlZibM_vBt7FvUOsPmeXGcyG9uhzrgjVEPxlnuU3vD6lrYTOTggDYWTly_inZlJrK9xpFZfD0oD_RkCakc5kSjI6bRumasxm7HJ-ERn8ndxFs-_973SnMCPSvOO/s1600-h/singleton_04_extractConstant.PNG&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmNJ6LerFUIaW0wF5IOrlZibM_vBt7FvUOsPmeXGcyG9uhzrgjVEPxlnuU3vD6lrYTOTggDYWTly_inZlJrK9xpFZfD0oD_RkCakc5kSjI6bRumasxm7HJ-ERn8ndxFs-_973SnMCPSvOO/s400/singleton_04_extractConstant.PNG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5070376395803824178&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;ul&gt;&lt;li&gt;In a dialog you can change &#39;Constant name&#39; and visibility but &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_0&quot;&gt;typically&lt;/span&gt; the default value is OK. So just press &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;Enter&lt;/span&gt; or click OK and voila ....&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaTLCZkqCbPUqWIqhLkK3_PTZ6s68ty4d4Ki9Plh-IQPvMTbTjuf9ipkMjcumbm1lG4alBpUgH5J0FJIRv80O8fgpTEjrIg-WKAT4OXvlN3ytdfRKJa6ifA9zTaNYvKpVaWKACI9PsXsq2/s1600-h/singleton_05_Singleton.PNG&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaTLCZkqCbPUqWIqhLkK3_PTZ6s68ty4d4Ki9Plh-IQPvMTbTjuf9ipkMjcumbm1lG4alBpUgH5J0FJIRv80O8fgpTEjrIg-WKAT4OXvlN3ytdfRKJa6ifA9zTaNYvKpVaWKACI9PsXsq2/s400/singleton_05_Singleton.PNG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5070383469614960706&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;The result is full-value Singleton design pattern implementation created in 4 very simple steps.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;div&gt;&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-9722020934797923&quot;;
/* Blog-Bosy-Feeds */
google_ad_slot = &quot;1800980789&quot;;
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bosy.dailydev.org/feeds/3114380879487336716/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4345824448663422013/3114380879487336716' title='12 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4345824448663422013/posts/default/3114380879487336716'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4345824448663422013/posts/default/3114380879487336716'/><link rel='alternate' type='text/html' href='http://bosy.dailydev.org/2007/06/singleton-pattern-implementation-in-4.html' title='Singleton pattern implementation in 4 steps'/><author><name>Roman B.</name><uri>http://www.blogger.com/profile/10191921864885167276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkirYxIJPACQfNIWSqesYxil1ok4R_MZZi-NbTfLuH3fH-m0wpbpv4M0F3LiEH-fECVXRvOCndh9EKisu9izUw3_0W3Nimc-VeToP5dPdDE7SbhlB-amp058iDgu-_jyaeZ9NIc9LOt1_R/s72-c/singleton_02_EmptyClass.PNG" height="72" width="72"/><thr:total>12</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4345824448663422013.post-109993365380576097</id><published>2007-05-16T18:15:00.000+02:00</published><updated>2007-06-20T11:25:58.182+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="coding tips"/><category scheme="http://www.blogger.com/atom/ns#" term="content assistant"/><category scheme="http://www.blogger.com/atom/ns#" term="Eclipse"/><title type='text'>Code Content Assistant Efficiency</title><content type='html'>&lt;span style=&quot;font-weight: bold;font-size:85%;&quot; &gt;Purpose of this article is to evaluate efficiency of content assistant functionality provided by Eclipse with focus on type name completion. The results will be of course applicable not just for type names but also for field and method names.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;font-size:100%;&quot; &gt;Content assistant functionality&lt;/span&gt;&lt;br /&gt;Eclipse content assistant is simply suggesting code completions while writing code considering to concrete context - type names, field names, method names, ... It also provides excellent feature called &quot;camel case matches&quot; (NPE matches to NullPointerException) which is also object of my evaluation.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Content assistant efficiency definition&lt;/span&gt;&lt;br /&gt;Content assistant efficiency is number, which says how many times more you will get considering to what you spend. When we are talking about type names then this number is defined as &lt;span style=&quot;font-weight: bold;font-family:courier new;&quot; &gt;typeNameLength/price&lt;/span&gt;. Where &lt;span style=&quot;font-weight: bold;font-family:courier new;&quot; &gt;typeNameLength&lt;/span&gt; is simply the number of letters in the type name. The &lt;span style=&quot;font-weight: bold;font-family:courier new;&quot; &gt;price&lt;/span&gt; is lowest number of letters and key presses (arrow down in suggestion list + Enter) necessary to be pressed to generate type name using content assistant.&lt;br /&gt;&lt;br /&gt;For example class &lt;span style=&quot;font-family:courier new;&quot;&gt;NullPointerException&lt;/span&gt; has &lt;span style=&quot;font-weight: bold;&quot;&gt;20&lt;/span&gt; letters but using content assistant we can generate the name by &lt;span style=&quot;font-weight: bold;&quot;&gt;5&lt;/span&gt; key presses &lt;span style=&quot;font-size:85%;&quot;&gt;(typing &quot;NPE&quot; + one down arrow press, because NoPermissionException is also in the list + Enter)&lt;/span&gt;. It means that in case of &lt;span style=&quot;font-family:courier new;&quot;&gt;NullPointerException&lt;/span&gt; class the efficiency of content assistant is &lt;span style=&quot;font-weight: bold;&quot;&gt;20/5=4&lt;/span&gt;. Basically it means that the result is four time bigger than the effort to generate it.&lt;br /&gt;&lt;br /&gt;The example is talking just about one class. But it can be also applicable for set of classes (eg. jar) simply counting their lengths together and dividing by counted prices.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;How I evaluated&lt;/span&gt;&lt;br /&gt;Of course the biggest challenge was to find lowest number of letters and key presses necessary to be pressed to generate the type name. For this purpose I wrote simple application which for 3905 patterns (maximum 5 words with maximum 5 letters) distributes classes by name into groups where classes in one group matches the pattern with same result. After alphabetical sort of the classes in the group it counts price for every class as length of group id + position in the sorted list (first = 0) + 1 (Enter). The lowest price for a class over all groups is the number what we are looking for.&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;Pattern: ^([A-Z])[^A-Z]([A-Z])[^A-Z]([A-Z])[^A-Z].*$&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;Group Id: NPE&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;Sorted classes: NoPermissionException, NullPointerException&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;Prices: 3+0+1=4, 3+1+1=5&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;Pattern: ^([A-Z][^A-Z]{1})[^A-Z]([A-Z])[^A-Z]([A-Z])[^A-Z].*$&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;Group Id: NoPE&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;Sorted classes: NoPermissionException&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;Prices: 4+0+1=5&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;Lower price for NoPermissionException class is in the first group so it is the lowest price.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;For evaluation I used classes from seven jars (rt.jar, catalina.jar, xercesImpl.jar, derby.jar, xalan.jar, axis.jar, junit.jar) with total number of 12707 classes.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Results&lt;/span&gt;&lt;br /&gt;As we can see in the table below the content assistant efficiency counted for all seven jars together is &lt;span style=&quot;font-weight: bold;&quot;&gt;3.20&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGL9WvoCykuu3-X8XLo-oJRt9zc4HOQrAwlNRpUv4KEKi3Wo4nz36vgZyr503L7Ly7FxyhJ52xRKJB9gzQuQZQgPt0SmKcefKzoNMJycM8VMCoxqYikReh3ir5u9VAmBy2ILpeVUxfGmtj/s1600-h/efficiencyTable.PNG&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGL9WvoCykuu3-X8XLo-oJRt9zc4HOQrAwlNRpUv4KEKi3Wo4nz36vgZyr503L7Ly7FxyhJ52xRKJB9gzQuQZQgPt0SmKcefKzoNMJycM8VMCoxqYikReh3ir5u9VAmBy2ILpeVUxfGmtj/s400/efficiencyTable.PNG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5065210744147644306&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;It means that using content assistant is about three times more effectively than typing everything. The second benefit of content assistant usage is higher quality of code, because it is harder to make mistakes.&lt;br /&gt;&lt;br /&gt;All this can be true just in case that the user uses content assistant effectively. About how to really use it and what are the best practises see &lt;span style=&quot;font-weight: bold;&quot;&gt;TBD - article about effective useage is in progress&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Attachment&lt;/span&gt;&lt;br /&gt;On chart in the image bellow we can see a histograms of class name length and class price. It shows number of classes with concrete length (blue) and number of classes for price (red). We can see the efficiency of the content assistant as a peek of red bars in comparison with blue &quot;hill&quot;.&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBaka74zPAn4Fu4hJjC1GiZ4SAco51T-2n44ZHzVurc1UlgfEvhkmJy4F2wQ0-AlXt6ZEX_kY9L99RREUinnCB2bvydLQNB3pDg1zw_pUMjm-hBIK0h2-aCO063V39JiJHghum7Q5j8Hkj/s1600-h/priceHistograms.PNG&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBaka74zPAn4Fu4hJjC1GiZ4SAco51T-2n44ZHzVurc1UlgfEvhkmJy4F2wQ0-AlXt6ZEX_kY9L99RREUinnCB2bvydLQNB3pDg1zw_pUMjm-hBIK0h2-aCO063V39JiJHghum7Q5j8Hkj/s400/priceHistograms.PNG&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5070021764649160658&quot; /&gt;&lt;/a&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;div&gt;&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-9722020934797923&quot;;
/* Blog-Bosy-Feeds */
google_ad_slot = &quot;1800980789&quot;;
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bosy.dailydev.org/feeds/109993365380576097/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4345824448663422013/109993365380576097' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4345824448663422013/posts/default/109993365380576097'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4345824448663422013/posts/default/109993365380576097'/><link rel='alternate' type='text/html' href='http://bosy.dailydev.org/2007/05/content-assistant-efficiency.html' title='Code Content Assistant Efficiency'/><author><name>Roman B.</name><uri>http://www.blogger.com/profile/10191921864885167276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGL9WvoCykuu3-X8XLo-oJRt9zc4HOQrAwlNRpUv4KEKi3Wo4nz36vgZyr503L7Ly7FxyhJ52xRKJB9gzQuQZQgPt0SmKcefKzoNMJycM8VMCoxqYikReh3ir5u9VAmBy2ILpeVUxfGmtj/s72-c/efficiencyTable.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4345824448663422013.post-5752205455729197509</id><published>2007-04-20T09:13:00.000+02:00</published><updated>2007-07-04T08:20:04.283+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="coding tips"/><category scheme="http://www.blogger.com/atom/ns#" term="Eclipse"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="refactoring"/><title type='text'>Don&#39;t write code - use Eclipse</title><content type='html'>&lt;div style=&quot;float: right;&quot;&gt;&lt;iframe src=&quot;http://rcm.amazon.com/e/cm?t=dailydevelo-20&amp;o=1&amp;p=8&amp;l=as1&amp;asins=0596007108&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr&quot; style=&quot;width:120px;height:240px;&quot; scrolling=&quot;no&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;&lt;/div&gt;Eclipse IDE provides multiple functionalities which can help you when you are coding. The functionalities what I am talking about are typically very small and easy to use actions such as Content Assistant, Quick Fix, Refactoring and other code manipulations. Usage of those features can improve speed and quality of your coding.&lt;br /&gt;&lt;br /&gt;In this article and also in the other articles under label &lt;a href=&quot;http://dailydevelopment.blogspot.com/search/label/coding%20tips&quot;&gt;coding tips&lt;/a&gt; I would like to describe usage of those features in the way where you will write as little code as possible and the rest of code will be generated by Eclipse.&lt;br /&gt;&lt;br /&gt;Let start with very simple example - assignment of new instance of StringBuffer class to the local variable or to the field.&lt;br /&gt;&lt;br /&gt;So what we want to have at the and will be something like:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;font-family:courier new;&quot; &gt;StringBuffer buffer = new StringBuffer();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Steps:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;write keyword &#39;&lt;span style=&quot;font-weight: bold;font-family:courier new;&quot; &gt;n&lt;/span&gt;&lt;span style=&quot;font-weight: bold;font-family:courier new;&quot; &gt;ew&lt;/span&gt;&#39;&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img style=&quot;cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8H5nU6trXNRNCQL22EKCJPUsWkeX3z7irUWhY-eD2cjPLyA6zzrGq2Bd8oyN9CisiJPcS8huDgfRt7DBQ65FCNfmZvQCzbkdW-OWwyX4NSE4mqTRIf181wPjif4iYvGdmKqBKCPaszTRV/s400/new.PNG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5057018632003643842&quot; border=&quot;0&quot; /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;write &#39;&lt;span style=&quot;font-weight: bold;&quot;&gt;S&lt;/span&gt;&#39; and push &lt;span style=&quot;font-style: italic;&quot;&gt;Ctrl+Space&lt;/span&gt; (shortcut for Content Assistant)&lt;br /&gt;you can see list of classes, interfaces and templates starting with &#39;&lt;span style=&quot;font-weight: bold;&quot;&gt;S&lt;/span&gt;&#39;&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKB7jeSRfOliUF9o4EGuVW5zvDCi98g16hOeZ3fRivCKTN5WKZ4MCnfMiXHRdtbp8WvkLWpi1RvoWh4bvbjcq9j4MyoDM8EO9OjQ7K5imKehldc9yM9P8ExTsinUahrCRA8eJ8ikJi9q0i/s1600-h/newS.PNG&quot;&gt;&lt;img style=&quot;cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKB7jeSRfOliUF9o4EGuVW5zvDCi98g16hOeZ3fRivCKTN5WKZ4MCnfMiXHRdtbp8WvkLWpi1RvoWh4bvbjcq9j4MyoDM8EO9OjQ7K5imKehldc9yM9P8ExTsinUahrCRA8eJ8ikJi9q0i/s400/newS.PNG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5057019679975664082&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;you can specify more accurately the name of requested class writing its following letters &#39;&lt;span style=&quot;font-weight: bold;font-family:courier new;&quot; &gt;tr&lt;/span&gt;&#39; or using Camel feature - just write &#39;B&#39; as a Buffer. Then navigate selection to StringBuffer class.&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQ-WMlZ3VyEl4AgfDdeoXAN0UeIsRuDAjFjwHIz075xsg2i_jTaAKfU67noKkDGviqlU4DAqvoXZVCJnOvL2AeIccZf04eL2QjGqMz_BEOg7Dexx4Lq3r2ntNDHNDCtRKxCMYmEjIfkxYZ/s1600-h/newSB.PNG&quot;&gt;&lt;img style=&quot;cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQ-WMlZ3VyEl4AgfDdeoXAN0UeIsRuDAjFjwHIz075xsg2i_jTaAKfU67noKkDGviqlU4DAqvoXZVCJnOvL2AeIccZf04eL2QjGqMz_BEOg7Dexx4Lq3r2ntNDHNDCtRKxCMYmEjIfkxYZ/s400/newSB.PNG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5057020676408076770&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;press &lt;span style=&quot;font-style: italic;&quot;&gt;Enter&lt;/span&gt;. The name of the class is generated.&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJf9LY77bcjupjpGxVHuuLGI-5X_MbOKML-X_lUXlpNpVgXbfplrZESEC_K5GysAarORJ7oyPL3PHuc-HabIS7gRKhTMnVRZyd3t1kY4RozcYt3gnUvs6qgXE1NEYV6kB9HFa93bjFsY0a/s1600-h/newStringBuffer.PNG&quot;&gt;&lt;img style=&quot;cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJf9LY77bcjupjpGxVHuuLGI-5X_MbOKML-X_lUXlpNpVgXbfplrZESEC_K5GysAarORJ7oyPL3PHuc-HabIS7gRKhTMnVRZyd3t1kY4RozcYt3gnUvs6qgXE1NEYV6kB9HFa93bjFsY0a/s400/newStringBuffer.PNG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5057024267000736242&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;write &#39;&lt;span style=&quot;font-weight: bold;&quot;&gt;(&lt;/span&gt;&#39; as an open parenthesis (the closing parenthesis is generated automatically) for constructor parameters and and push &lt;span style=&quot;font-style: italic;&quot;&gt;Ctrl+Space&lt;/span&gt; again.&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi78nKdVJRlqacFP_AWr5GwUylrdkZY0n3hCpHexrWg8wrVEcvmyPH2UQbaRjA_NxhwyXuyRQb11CpRsKFGaDqH70gB7BZGIOrVDpekC3A4B4tYCdCrbhthE02HMSkbm7E_fm1UaNP5NC9p/s1600-h/newStringBufferC.PNG&quot;&gt;&lt;img style=&quot;cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi78nKdVJRlqacFP_AWr5GwUylrdkZY0n3hCpHexrWg8wrVEcvmyPH2UQbaRjA_NxhwyXuyRQb11CpRsKFGaDqH70gB7BZGIOrVDpekC3A4B4tYCdCrbhthE02HMSkbm7E_fm1UaNP5NC9p/s400/newStringBufferC.PNG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5057025692929878530&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;select constructor you want to use and press &lt;span style=&quot;font-style: italic;&quot;&gt;Enter&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqIzcUkakuOSVcVi-pgm2cvqNXFcH9wqsRIcePG0QirsO4YyezwDKsnmIEpgDjSa7zMTTN-5SqiC-qwL4PeVrFrr2YDIGsoK6t0PQikuevSg12Un6YYgjvU7LM4uQyPlKXqEk08_n1nIBp/s1600-h/newStringBufferC2.PNG&quot;&gt;&lt;img style=&quot;cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqIzcUkakuOSVcVi-pgm2cvqNXFcH9wqsRIcePG0QirsO4YyezwDKsnmIEpgDjSa7zMTTN-5SqiC-qwL4PeVrFrr2YDIGsoK6t0PQikuevSg12Un6YYgjvU7LM4uQyPlKXqEk08_n1nIBp/s400/newStringBufferC2.PNG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5057027123153988114&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;write down the parameter values for the constructor, press &lt;span style=&quot;font-style: italic;&quot;&gt;End &lt;/span&gt;button, add semicolon &#39;&lt;span style=&quot;font-weight: bold;&quot;&gt;;&lt;/span&gt;&#39; and save (off course using &lt;span style=&quot;font-style: italic;&quot;&gt;Ctr+S&lt;/span&gt; shortcut).&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwTFZ_LV10cwkxrlPtjib4QuZJX1egyQd1rsVbSHyoKO2Pmv_fMkhm8U0kQGUm4JaQ-q6BvQQRdhDzSXdoNjc99SMCjoqXmTE8G1Rm4Qk3OVPe2yCUbGDJXK04rrNqYKCP3EsAdDhInxHt/s1600-h/newStringBufferC3.PNG&quot;&gt;&lt;img style=&quot;cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwTFZ_LV10cwkxrlPtjib4QuZJX1egyQd1rsVbSHyoKO2Pmv_fMkhm8U0kQGUm4JaQ-q6BvQQRdhDzSXdoNjc99SMCjoqXmTE8G1Rm4Qk3OVPe2yCUbGDJXK04rrNqYKCP3EsAdDhInxHt/s400/newStringBufferC3.PNG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5057027836118559266&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;press &lt;span style=&quot;font-style: italic;&quot;&gt;Ctrl+1&lt;/span&gt; (cursor should be somewhere on the line code). It is shortcut for Quick Fix proposal.&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbiRSAkZcDjwsbl4cMEmOPhvnPhHUWlx5_9I3Ggr2SQfT3drhYn2ZeEc2pFf9r4grP3PjXqNFhNb2Z_7olj9ZwYTwkq4kJ36v5bW7pCTjmgFxh-ea1CBilj-BwM3wpEKoeK31MhSryzUxH/s1600-h/newStringBufferQF1.PNG&quot;&gt;&lt;img style=&quot;cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbiRSAkZcDjwsbl4cMEmOPhvnPhHUWlx5_9I3Ggr2SQfT3drhYn2ZeEc2pFf9r4grP3PjXqNFhNb2Z_7olj9ZwYTwkq4kJ36v5bW7pCTjmgFxh-ea1CBilj-BwM3wpEKoeK31MhSryzUxH/s400/newStringBufferQF1.PNG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5057030894135274034&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;choose one of the proposals and press &lt;span style=&quot;font-style: italic;&quot;&gt;Enter&lt;/span&gt;. The Eclipse then generates all necessary code to have it compile able.&lt;br /&gt;For more advanced usage you can use direct shortcuts for proposed actions (you can see them in the proposal) - &lt;span style=&quot;font-style: italic;&quot;&gt;Ctrl+2, L&lt;/span&gt; for assignment to local variable and &lt;span style=&quot;font-style: italic;&quot;&gt;Ctrl+2, F&lt;/span&gt; for assignment to field.&lt;br /&gt;It also provides you possibility to give a name of created variable or field.&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFNVFTh5C2VkoetCzAS41y1WQZIbE982GGuG8aK_usv-51pf39mN7KBfP4nvIMzImdUhwK1CSDN2UxBXJs8MAmbnIX1ZzlZsJl2zakyHFpzl01BP6rLmw2paSRMLRzrgRmNi8v5OFRiNbz/s1600-h/newStringBufferQF2.PNG&quot;&gt;&lt;img style=&quot;cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFNVFTh5C2VkoetCzAS41y1WQZIbE982GGuG8aK_usv-51pf39mN7KBfP4nvIMzImdUhwK1CSDN2UxBXJs8MAmbnIX1ZzlZsJl2zakyHFpzl01BP6rLmw2paSRMLRzrgRmNi8v5OFRiNbz/s400/newStringBufferQF2.PNG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5057033333676698178&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;When you are sure about the name of the variable press &lt;span style=&quot;font-style: italic;&quot;&gt;Enter&lt;/span&gt;. It will offer you to specify type of variable in more detail. Of course the proposed types are super types of the type you instantiated.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxa-96jv1K4rwEEbC7RAZtx8VseCTjpF5N1kJyI-qkm3ALvnKRqqDHSjWXRiC6TNBVpgVKKd-8ZWek8gQWsO4PpT45EJKIzhh_iFInnf1c3hyphenhyphennDzHXi79azaeNZjiPX4UC694GbTK9dGtg/s1600-h/newStringBufferQF3.PNG&quot;&gt;&lt;img style=&quot;cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxa-96jv1K4rwEEbC7RAZtx8VseCTjpF5N1kJyI-qkm3ALvnKRqqDHSjWXRiC6TNBVpgVKKd-8ZWek8gQWsO4PpT45EJKIzhh_iFInnf1c3hyphenhyphennDzHXi79azaeNZjiPX4UC694GbTK9dGtg/s400/newStringBufferQF3.PNG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5057033509770357330&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt; When you will choose the right type press siply &lt;span style=&quot;font-style: italic;&quot;&gt;Enter &lt;/span&gt;again and once more for finalization.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3RU0HJOYXDWMDghf1dyVnSuKEi4mTZ4CDKmyd0y5JpPlOxaZdLoGsx3TfFtSJ45dSEzYMneTfjOR5DXR1du7uv_uXyyVMySez6rkiFpCq-Rcpg8_LQWyVoF0McuuW4ndn4dUUxLEMnj8X/s1600-h/final.PNG&quot;&gt;&lt;img style=&quot;cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3RU0HJOYXDWMDghf1dyVnSuKEi4mTZ4CDKmyd0y5JpPlOxaZdLoGsx3TfFtSJ45dSEzYMneTfjOR5DXR1du7uv_uXyyVMySez6rkiFpCq-Rcpg8_LQWyVoF0McuuW4ndn4dUUxLEMnj8X/s400/final.PNG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5057034596397083234&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;Now we have what we wanted (55 characters) using 28 key presses.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;div&gt;&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-9722020934797923&quot;;
/* Blog-Bosy-Feeds */
google_ad_slot = &quot;1800980789&quot;;
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bosy.dailydev.org/feeds/5752205455729197509/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4345824448663422013/5752205455729197509' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4345824448663422013/posts/default/5752205455729197509'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4345824448663422013/posts/default/5752205455729197509'/><link rel='alternate' type='text/html' href='http://bosy.dailydev.org/2007/04/dont-write-code-use-eclipse.html' title='Don&#39;t write code - use Eclipse'/><author><name>Roman B.</name><uri>http://www.blogger.com/profile/10191921864885167276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8H5nU6trXNRNCQL22EKCJPUsWkeX3z7irUWhY-eD2cjPLyA6zzrGq2Bd8oyN9CisiJPcS8huDgfRt7DBQ65FCNfmZvQCzbkdW-OWwyX4NSE4mqTRIf181wPjif4iYvGdmKqBKCPaszTRV/s72-c/new.PNG" height="72" width="72"/><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4345824448663422013.post-1685750448322207627</id><published>2007-04-11T16:01:00.000+02:00</published><updated>2007-06-18T16:06:35.482+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="architecture"/><category scheme="http://www.blogger.com/atom/ns#" term="design patterns"/><category scheme="http://www.blogger.com/atom/ns#" term="interceptor"/><category scheme="http://www.blogger.com/atom/ns#" term="J2EE"/><title type='text'>Interceptor Design Pattern</title><content type='html'>Usage of Interceptor Design Pattern [&lt;a href=&quot;http://www.blogger.com/%20%20%20http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=http%3A%2F%2Fwww.amazon.com%2FPattern-Oriented-Software-Architecture-Concurrent-Networked%2Fdp%2F0471606952%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1181656011%26sr%3D8-1&amp;amp;amp;amp;amp;tag=dailydevelo-20&amp;linkCode=ur2&amp;amp;camp=1789&amp;creative=9325%20&quot;&gt;POSA2&lt;/a&gt;&lt;img style=&quot;BORDER-RIGHT: 0px; PADDING-RIGHT: 0px! important; BORDER-TOP: 0px; PADDING-LEFT: 0px! important; PADDING-BOTTOM: 0px! important; MARGIN: 0px; BORDER-LEFT: 0px; PADDING-TOP: 0px! important; BORDER-BOTTOM: 0px&quot; height=&quot;0&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=dailydevelo-20&amp;l=ur2&amp;amp;o=1&quot; width=&quot;0&quot; border=&quot;0&quot; /&gt;] can solve many problems in daily development. It is very easy to: &lt;ul&gt;&lt;li&gt;monitor what is the application doing inside&lt;/li&gt;&lt;li&gt;provide possibility to change some of application&#39;s behavior&lt;/li&gt;&lt;li&gt;provide possibility to extend application with new features&lt;/li&gt;&lt;ul&gt;&lt;li&gt;implementer of the extension need not to know rest of the application&lt;/li&gt;&lt;li&gt;implementer of the extension need not change existing code&lt;/li&gt;&lt;li&gt;new extensions can or can not affect current system&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;Interceptor design pattern is built from three basic components: &lt;ol&gt;&lt;li&gt;IInterceptor interface&lt;/li&gt;&lt;li&gt;Dispatcher&lt;/li&gt;&lt;li&gt;Context&lt;/li&gt;&lt;/ol&gt;&lt;div style=&quot;TEXT-ALIGN: center&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1GrMyk4Cd0qycplbkRLIuQ-5AKzK3pOLSkRANcB_T1CB3slXBluJbZt5wLjvcB6TIiwkMzCtjcx0Qj2SqwuqBQY5_P4p2muyCVtSg3r9LdXZ5Fbbzeir6DRJT5nQy1lLPZbKB_SdBvW7o/s1600-h/InterceptorClassDiagram.png+&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5063211189862717922&quot; style=&quot;CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1GrMyk4Cd0qycplbkRLIuQ-5AKzK3pOLSkRANcB_T1CB3slXBluJbZt5wLjvcB6TIiwkMzCtjcx0Qj2SqwuqBQY5_P4p2muyCVtSg3r9LdXZ5Fbbzeir6DRJT5nQy1lLPZbKB_SdBvW7o/s320/InterceptorClassDiagram.png+&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style=&quot;FONT-WEIGHT: bold;font-size:85%;&quot; &gt;IInterceptor&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; - &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;IInterceptor &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;interface&lt;/span&gt; can define arbitrary number of operations which are executed by &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Dispatcher&lt;/span&gt; in specific cases (at the beginning of the request processing or at the end of the request processing). There is typically just one parameter for every method - &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Context&lt;/span&gt; - carrying input and output data. The interface is then implemented by specific interceptors (logging, authorization, transaction, ...).&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;FONT-WEIGHT: bold;font-size:85%;&quot; &gt;Dispatcher&lt;/span&gt; - &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Dispatch&lt;/span&gt;&lt;span style=&quot;FONT-STYLE: italic&quot;&gt;er &lt;/span&gt;class typically implements &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;IInterceptor &lt;/span&gt;interface. There are many ways how the dispatching can be implemented. For example the interceptors called by &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Dispatcher &lt;/span&gt;can be prioritized or exception thrown from interceptor can be handled as interception termination. The &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Dispatcher &lt;/span&gt;is the class which is called from &quot;intercepting point&quot; to perform intercepting.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;FONT-WEIGHT: bold;font-size:85%;&quot; &gt;Context&lt;/span&gt; - &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Context&lt;/span&gt; is typically simple data object used to carry data for interceptors or to keep results of intercepting (eg. transaction id generated by TransactionInterceptor). There can be different &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Context &lt;/span&gt;implementations not only for different &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;IInterceptor&lt;/span&gt; interfaces but also for different methods of &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;IInterceptor&lt;/span&gt; interface.&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;TEXT-ALIGN: center&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh27J_LjbN4IB4BNQReXsBe5e6PALgdkn4uDX3Y_Qn2MlmKvPKxSnPl0pipw_GsPJzZ_8uel0ewGFv2deGiQP681bKzvlAY0NGTUqRXs0V3P_xCzMy-ralCTNlBrzAuvsvlVu5Ly8xZwQfw/s1600-h/InterceptorSequenceDiagram.png+&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5063212482647874034&quot; style=&quot;CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh27J_LjbN4IB4BNQReXsBe5e6PALgdkn4uDX3Y_Qn2MlmKvPKxSnPl0pipw_GsPJzZ_8uel0ewGFv2deGiQP681bKzvlAY0NGTUqRXs0V3P_xCzMy-ralCTNlBrzAuvsvlVu5Ly8xZwQfw/s320/InterceptorSequenceDiagram.png+&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;As mentioned in description of basic elements the Interceptor pattern has many degree of freedom:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;IInterceptor&lt;/li&gt;&lt;ul&gt;&lt;li&gt;one/many methods&lt;/li&gt;&lt;li&gt;one/many &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Context&lt;/span&gt; types for many methods&lt;/li&gt;&lt;li&gt;result propagation to &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Dispatcher&lt;/span&gt;, intercepting point or following interceptors&lt;span style=&quot;FONT-STYLE: italic&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Context&lt;/span&gt; - &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Dispatcher&lt;/span&gt; can decide about next step by status of the &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Context&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Exception&lt;/span&gt; - &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Dispatcher &lt;/span&gt;can handle different exceptions different way&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;li&gt;Dispatcher&lt;/li&gt;&lt;ul&gt;&lt;li&gt;implements/does not implement IInterceptor interface&lt;/li&gt;&lt;li&gt;dispatching mechanism (prioritized, random, based on context, ...)&lt;/li&gt;&lt;/ul&gt;&lt;/ol&gt;Implementation of Interceptor Pattern is not the easiest work. But whenever it is implemented it is very simple to extend application by new features or change its behavior.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;FONT-WEIGHT: bold&quot;&gt;Related patterns:&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li style=&quot;FONT-WEIGHT: bold&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Template Method&lt;/span&gt; [&lt;a href=&quot;http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=http%3A%2F%2Fwww.amazon.com%2FDesign-Patterns-Object-Oriented-Addison-Wesley-Professional%2Fdp%2F0201633612%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1182152591%26sr%3D1-1&amp;amp;amp;amp;amp;tag=dailydevelo-20&amp;linkCode=ur2&amp;amp;camp=1789&amp;creative=9325&quot;&gt;GoF&lt;/a&gt;&lt;img style=&quot;BORDER-RIGHT: 0px; PADDING-RIGHT: 0px! important; BORDER-TOP: 0px; PADDING-LEFT: 0px! important; PADDING-BOTTOM: 0px! important; MARGIN: 0px; BORDER-LEFT: 0px; PADDING-TOP: 0px! important; BORDER-BOTTOM: 0px&quot; height=&quot;0&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=dailydevelo-20&amp;l=ur2&amp;amp;o=1&quot; width=&quot;0&quot; border=&quot;0&quot; /&gt;]&lt;/li&gt;&lt;ul&gt;&lt;li style=&quot;FONT-WEIGHT: normal&quot;&gt;Very simple version of Interceptor Pattern implementing &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Dispatcher &lt;/span&gt;(template method) and &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;IInterceptor &lt;/span&gt;implementations (methods called from template method) in one class.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li style=&quot;FONT-WEIGHT: bold&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Chain of Responsibility&lt;/span&gt; [&lt;a href=&quot;http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=http%3A%2F%2Fwww.amazon.com%2FDesign-Patterns-Object-Oriented-Addison-Wesley-Professional%2Fdp%2F0201633612%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1182152591%26sr%3D1-1&amp;amp;amp;amp;amp;tag=dailydevelo-20&amp;linkCode=ur2&amp;amp;camp=1789&amp;creative=9325&quot;&gt;GoF&lt;/a&gt;&lt;img style=&quot;BORDER-RIGHT: 0px; PADDING-RIGHT: 0px! important; BORDER-TOP: 0px; PADDING-LEFT: 0px! important; PADDING-BOTTOM: 0px! important; MARGIN: 0px; BORDER-LEFT: 0px; PADDING-TOP: 0px! important; BORDER-BOTTOM: 0px&quot; height=&quot;0&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=dailydevelo-20&amp;l=ur2&amp;amp;o=1&quot; width=&quot;0&quot; border=&quot;0&quot; /&gt;]&lt;/li&gt;&lt;ul&gt;&lt;li style=&quot;FONT-WEIGHT: normal&quot;&gt;Does not have &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Dispatcher &lt;/span&gt;- the order of &quot;interceptors&quot; is defined as chain of successors.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li style=&quot;FONT-WEIGHT: bold&quot;&gt;&lt;a href=&quot;http://dailydevelopment.blogspot.com/2007/04/intercepting-filter-design-pattern.html&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Intercepting Filter&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;ul&gt;&lt;li style=&quot;FONT-WEIGHT: normal&quot;&gt;Similar also to Chain of Responsibility but the chain of successors is not &quot;hard coded&quot; but propagated to &quot;interceptor&quot; as parameter of the method call.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style=&quot;FONT-WEIGHT: bold&quot;&gt;References:&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li style=&quot;font-size:85%;font-weight: bold;&quot;&gt;&lt;a href=&quot;http://www.cs.uu.nl/docs/vakken/no/interceptor.pdf&quot;&gt;Intreceptor Design Pattern presentation&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;font-size:85%;font-weight: bold;&quot;&gt;&lt;a href=&quot;http://www.onjava.com/pub/a/onjava/2003/09/17/patterns.html&quot;&gt;ONJava - Web and Enterprise Architecture Design Patterns for J2EE, Part 2&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;div&gt;&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-9722020934797923&quot;;
/* Blog-Bosy-Feeds */
google_ad_slot = &quot;1800980789&quot;;
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bosy.dailydev.org/feeds/1685750448322207627/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4345824448663422013/1685750448322207627' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4345824448663422013/posts/default/1685750448322207627'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4345824448663422013/posts/default/1685750448322207627'/><link rel='alternate' type='text/html' href='http://bosy.dailydev.org/2007/04/interceptor-design-pattern.html' title='Interceptor Design Pattern'/><author><name>Roman B.</name><uri>http://www.blogger.com/profile/10191921864885167276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1GrMyk4Cd0qycplbkRLIuQ-5AKzK3pOLSkRANcB_T1CB3slXBluJbZt5wLjvcB6TIiwkMzCtjcx0Qj2SqwuqBQY5_P4p2muyCVtSg3r9LdXZ5Fbbzeir6DRJT5nQy1lLPZbKB_SdBvW7o/s72-c/InterceptorClassDiagram.png+" height="72" width="72"/><thr:total>2</thr:total></entry></feed>