<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Taswar Bhatti Blog</title>
	
	<link>http://taswar.zeytinsoft.com</link>
	<description>The synonyms of software simplicity</description>
	<lastBuildDate>Thu, 14 Feb 2013 19:08:18 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/TaswarBhattiBlog" /><feedburner:info uri="taswarbhattiblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Stop yelling at the lettuce for not growing – Software Teams</title>
		<link>http://feedproxy.google.com/~r/TaswarBhattiBlog/~3/LDYk6SwrU3g/</link>
		<comments>http://taswar.zeytinsoft.com/2013/02/14/stop-yelling-at-the-lettuce-for-not-growing-software-teams/#comments</comments>
		<pubDate>Thu, 14 Feb 2013 19:03:04 +0000</pubDate>
		<dc:creator>taswar</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[team]]></category>

		<guid isPermaLink="false">http://taswar.zeytinsoft.com/?p=1311</guid>
		<description><![CDATA[I remember watching a talk on infoq by Michael Feathers. He said something about growing your teams organically like a garden. An example he gave is, you don&#8217;t yell at the lettuce for not growing, you have to nurture it and help it, try different things so that it grows better. If you have a [...]]]></description>
				<content:encoded><![CDATA[<p>I remember watching a talk on infoq by <a href="http://www.infoq.com/author/Michael-Feathers" title="Michael Feathers">Michael Feathers</a>. He said something about growing your teams organically like a garden. An example he gave is, you don&#8217;t yell at the lettuce for not growing, you have to nurture it and help it, try different things so that it grows better.</p>
<p>If you have a co-worker in your team not doing very well, you need to help them to become stronger, guide them, try different things, show them different ideas, pair with them.</p>
<p>The reality is every software project will have weeds (bad code), you need to pull the weeds out as the garden grows, clean it up, so that overall the software is growing more organically. By having a stronger team you will have less weeds.</p>
<p>For your process rather than just focusing on task base feature, one should also focus on code quality features. Don&#8217;t just focus on hammering the new feature out, have the time to go over items that need care. Refactor the code that you see lots of bug and write test in those areas.</p>
<p>From my experience, I have seen when a coworker tries to explain their problem to you they already have a solution in their mind and when they try to verbally explain to you they have in the back of their mind solved the issue already. And if its not the case give them ideas of how you perceive the problem and show them your take on it.</p>
<p>But by yelling and not helping the lettuce, the lettuce is not going to grow any better.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Ftaswar.zeytinsoft.com%2F2013%2F02%2F14%2Fstop-yelling-at-the-lettuce-for-not-growing-software-teams%2F&amp;title=Stop%20yelling%20at%20the%20lettuce%20for%20not%20growing%20%E2%80%93%20Software%20Teams" id="wpa2a_2"><img src="http://taswar.zeytinsoft.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><img src="http://feeds.feedburner.com/~r/TaswarBhattiBlog/~4/LDYk6SwrU3g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://taswar.zeytinsoft.com/2013/02/14/stop-yelling-at-the-lettuce-for-not-growing-software-teams/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://taswar.zeytinsoft.com/2013/02/14/stop-yelling-at-the-lettuce-for-not-growing-software-teams/</feedburner:origLink></item>
		<item>
		<title>C# Perf improvement data types or using Linq is faster?</title>
		<link>http://feedproxy.google.com/~r/TaswarBhattiBlog/~3/LdVhsVZrmUo/</link>
		<comments>http://taswar.zeytinsoft.com/2013/02/13/c-perf-improvement-or-using-linq-is-faster/#comments</comments>
		<pubDate>Wed, 13 Feb 2013 14:54:32 +0000</pubDate>
		<dc:creator>taswar</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Perf Testing]]></category>

		<guid isPermaLink="false">http://taswar.zeytinsoft.com/?p=1297</guid>
		<description><![CDATA[Recently I was asked a simple code to improve the performance, and at first I couldn&#8217;t see it but as you know your brain starts working when you aren&#8217;t thinking of the problem anymore. (It happen to me when I was driving) Anyway the problem on hand was there is a for loop and when [...]]]></description>
				<content:encoded><![CDATA[<p>Recently I was asked a simple code to improve the performance, and at first I couldn&#8217;t see it but as you know your brain starts working when you aren&#8217;t thinking of the problem anymore. (It happen to me when I was driving)</p>
<p>Anyway the problem on hand was there is a for loop and when there are 10000 clients it performs bad.<br />
Something along the line of.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1297code5'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12975"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p1297code5"><pre class="csharp" style="font-family:monospace;">List<span style="color: #008000;">&lt;</span>Client<span style="color: #008000;">&gt;</span> _client<span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> SendMessage<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> id<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  <span style="color: #0600FF; font-weight: bold;">foreach</span><span style="color: #008000;">&#40;</span>var c <span style="color: #0600FF; font-weight: bold;">in</span> _client<span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
     <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>c<span style="color: #008000;">.</span><span style="color: #0000FF;">Id</span> <span style="color: #008000;">==</span> id<span style="color: #008000;">&#41;</span>
     <span style="color: #008000;">&#123;</span> 
       c<span style="color: #008000;">.</span><span style="color: #0000FF;">SendMessage</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
       <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
     <span style="color: #008000;">&#125;</span>
  <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>So I went and wrote some code to see the perf using Linq and at the end using a Dictionary rather, since a dictionary is way faster in lookup, O(1) in this case.</p>
<p>Here is the code using a List and Linq together</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1297code6'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12976"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p1297code6"><pre class="csharp" style="font-family:monospace;"> <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>var client <span style="color: #0600FF; font-weight: bold;">in</span> _clients<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Where</span><span style="color: #008000;">&#40;</span>x <span style="color: #008000;">=&gt;</span> x<span style="color: #008000;">.</span><span style="color: #0000FF;">Id</span> <span style="color: #008000;">==</span> id<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
                client<span style="color: #008000;">.</span><span style="color: #0000FF;">SendMessage</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>and if we changed the datatype to Dictionary this was the code used</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1297code7'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12977"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code" id="p1297code7"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">//using tryget</span>
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>_clients<span style="color: #008000;">.</span><span style="color: #0000FF;">TryGetValue</span><span style="color: #008000;">&#40;</span>id, <span style="color: #0600FF; font-weight: bold;">out</span> c<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  c<span style="color: #008000;">.</span><span style="color: #0000FF;">SendMessage</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">//using linq</span>
 var c <span style="color: #008000;">=</span> _clients<span style="color: #008000;">.</span><span style="color: #0000FF;">FirstOrDefault</span><span style="color: #008000;">&#40;</span>x <span style="color: #008000;">=&gt;</span> x<span style="color: #008000;">.</span><span style="color: #0000FF;">Key</span> <span style="color: #008000;">==</span> id<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>c <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    c<span style="color: #008000;">.</span><span style="color: #0000FF;">SendMessage</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #008080; font-style: italic;">//using just an index</span>
 Client c <span style="color: #008000;">=</span> _clients<span style="color: #008000;">&#91;</span>id<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
&nbsp;
c<span style="color: #008000;">.</span><span style="color: #0000FF;">SendMessage</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>Here is the end result of using it on an i7 8G of ram machine.</p>
<p><a href="http://taswar.zeytinsoft.com/wp-content/uploads/2013/02/console.png"><img src="http://taswar.zeytinsoft.com/wp-content/uploads/2013/02/console.png" alt="console" width="677" height="342" class="alignleft size-full wp-image-1298" /></a></p>
<p>And the results show that using an index as a dictionary is definitely faster, but one also has to look at the number of data.<br />
Where there are only few data entry using linq is quite insignificant in performance but where there are millions of data, it really shows that it slows down.</p>
<p>Here is the rest of the code.</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1297code8'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12978"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
</pre></td><td class="code" id="p1297code8"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Collections.Generic</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Linq</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">namespace</span> PerfMeasureApp
<span style="color: #008000;">&#123;</span>
    <span style="color: #6666cc; font-weight: bold;">class</span> Program
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> Main<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> args<span style="color: #008000;">&#41;</span>       
        <span style="color: #008000;">&#123;</span>
            var queue <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> MessageQueue <span style="color: #008000;">&#123;</span>Clients <span style="color: #008000;">=</span> GenerateListClients<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
&nbsp;
            var fastQueue <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> MessageQueueSmart <span style="color: #008000;">&#123;</span>Clients <span style="color: #008000;">=</span> GenerateDictClients<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
&nbsp;
            queue<span style="color: #008000;">.</span><span style="color: #0000FF;">DoStuff</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;********************************************&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            queue<span style="color: #008000;">.</span><span style="color: #0000FF;">DoStuffLinq</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;********************************************&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            fastQueue<span style="color: #008000;">.</span><span style="color: #0000FF;">DoStuff</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">9999999</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;********************************************&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            fastQueue<span style="color: #008000;">.</span><span style="color: #0000FF;">DoStuffLinq</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">9999999</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;********************************************&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            fastQueue<span style="color: #008000;">.</span><span style="color: #0000FF;">DoStuffIndex</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">9999999</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;********************************************&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">Read</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">// Define other methods and classes here</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> List<span style="color: #008000;">&lt;</span>Client<span style="color: #008000;">&gt;</span> GenerateListClients<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            var list <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> List<span style="color: #008000;">&lt;</span>Client<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> <span style="color: #FF0000;">10000000</span><span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>i <span style="color: #008000;">==</span> <span style="color: #FF0000;">9999999</span><span style="color: #008000;">&#41;</span>
                    list<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Client<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">else</span>
                    list<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Client<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">return</span> list<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> Dictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">int</span>, Client<span style="color: #008000;">&gt;</span> GenerateDictClients<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            var dict <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Dictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">int</span>, Client<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> <span style="color: #FF0000;">10000000</span><span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                dict<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>i, <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Client<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">return</span> dict<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> MessageQueueSmart
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> IDictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">int</span>, Client<span style="color: #008000;">&gt;</span> _clients<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> IDictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">int</span>, Client<span style="color: #008000;">&gt;</span> Clients <span style="color: #008000;">&#123;</span> set <span style="color: #008000;">&#123;</span> _clients <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> DoStuff<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> id<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;MessageQueueSmart DoStuffTryGet&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #000000;">System.<span style="color: #0000FF;">Diagnostics</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Stopwatch</span> stopwatch <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #000000;">System.<span style="color: #0000FF;">Diagnostics</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Stopwatch</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            stopwatch<span style="color: #008000;">.</span><span style="color: #0000FF;">Start</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            Client c<span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>_clients<span style="color: #008000;">.</span><span style="color: #0000FF;">TryGetValue</span><span style="color: #008000;">&#40;</span>id, <span style="color: #0600FF; font-weight: bold;">out</span> c<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                c<span style="color: #008000;">.</span><span style="color: #0000FF;">SendMessage</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
&nbsp;
            stopwatch<span style="color: #008000;">.</span><span style="color: #0000FF;">Stop</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Time elapsed: {0}&quot;</span>, stopwatch<span style="color: #008000;">.</span><span style="color: #0000FF;">Elapsed</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> DoStuffLinq<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> id<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;MessageQueueSmart DoStuffLinq&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #000000;">System.<span style="color: #0000FF;">Diagnostics</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Stopwatch</span> stopwatch <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #000000;">System.<span style="color: #0000FF;">Diagnostics</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Stopwatch</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            stopwatch<span style="color: #008000;">.</span><span style="color: #0000FF;">Start</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            var c <span style="color: #008000;">=</span> _clients<span style="color: #008000;">.</span><span style="color: #0000FF;">FirstOrDefault</span><span style="color: #008000;">&#40;</span>x <span style="color: #008000;">=&gt;</span> x<span style="color: #008000;">.</span><span style="color: #0000FF;">Key</span> <span style="color: #008000;">==</span> id<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>c <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                c<span style="color: #008000;">.</span><span style="color: #0000FF;">SendMessage</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
&nbsp;
            stopwatch<span style="color: #008000;">.</span><span style="color: #0000FF;">Stop</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Time elapsed: {0}&quot;</span>, stopwatch<span style="color: #008000;">.</span><span style="color: #0000FF;">Elapsed</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> DoStuffIndex<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> id<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;MessageQueueSmart DoStuffIndex&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #000000;">System.<span style="color: #0000FF;">Diagnostics</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Stopwatch</span> stopwatch <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #000000;">System.<span style="color: #0000FF;">Diagnostics</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Stopwatch</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            stopwatch<span style="color: #008000;">.</span><span style="color: #0000FF;">Start</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            Client c <span style="color: #008000;">=</span> _clients<span style="color: #008000;">&#91;</span>id<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
&nbsp;
            c<span style="color: #008000;">.</span><span style="color: #0000FF;">SendMessage</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            stopwatch<span style="color: #008000;">.</span><span style="color: #0000FF;">Stop</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Time elapsed: {0}&quot;</span>, stopwatch<span style="color: #008000;">.</span><span style="color: #0000FF;">Elapsed</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> MessageQueue
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> List<span style="color: #008000;">&lt;</span>Client<span style="color: #008000;">&gt;</span> _clients<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> List<span style="color: #008000;">&lt;</span>Client<span style="color: #008000;">&gt;</span> Clients <span style="color: #008000;">&#123;</span> set <span style="color: #008000;">&#123;</span> _clients <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> DoStuff<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> id<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;MessageQueue DoStuff&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #000000;">System.<span style="color: #0000FF;">Diagnostics</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Stopwatch</span> stopwatch <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #000000;">System.<span style="color: #0000FF;">Diagnostics</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Stopwatch</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            stopwatch<span style="color: #008000;">.</span><span style="color: #0000FF;">Start</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>var client <span style="color: #0600FF; font-weight: bold;">in</span> _clients<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>client<span style="color: #008000;">.</span><span style="color: #0000FF;">Id</span> <span style="color: #008000;">==</span> id<span style="color: #008000;">&#41;</span>
                <span style="color: #008000;">&#123;</span>
                    client<span style="color: #008000;">.</span><span style="color: #0000FF;">SendMessage</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #008000;">&#125;</span>
            <span style="color: #008000;">&#125;</span>
            stopwatch<span style="color: #008000;">.</span><span style="color: #0000FF;">Stop</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Time elapsed: {0}&quot;</span>, stopwatch<span style="color: #008000;">.</span><span style="color: #0000FF;">Elapsed</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> DoStuffLinq<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> id<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;MessageQueue DoStuffLinq&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #000000;">System.<span style="color: #0000FF;">Diagnostics</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Stopwatch</span> stopwatch <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #000000;">System.<span style="color: #0000FF;">Diagnostics</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Stopwatch</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            stopwatch<span style="color: #008000;">.</span><span style="color: #0000FF;">Start</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>var client <span style="color: #0600FF; font-weight: bold;">in</span> _clients<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Where</span><span style="color: #008000;">&#40;</span>x <span style="color: #008000;">=&gt;</span> x<span style="color: #008000;">.</span><span style="color: #0000FF;">Id</span> <span style="color: #008000;">==</span> id<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                client<span style="color: #008000;">.</span><span style="color: #0000FF;">SendMessage</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
            stopwatch<span style="color: #008000;">.</span><span style="color: #0000FF;">Stop</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Time elapsed: {0}&quot;</span>, stopwatch<span style="color: #008000;">.</span><span style="color: #0000FF;">Elapsed</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> Client
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> Client<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> id<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Id <span style="color: #008000;">=</span> id<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> Id <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> SendMessage<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;SendMessage called &quot;</span> <span style="color: #008000;">+</span> Id<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
&nbsp;
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Ftaswar.zeytinsoft.com%2F2013%2F02%2F13%2Fc-perf-improvement-or-using-linq-is-faster%2F&amp;title=C%23%20Perf%20improvement%20data%20types%20or%20using%20Linq%20is%20faster%3F" id="wpa2a_4"><img src="http://taswar.zeytinsoft.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><img src="http://feeds.feedburner.com/~r/TaswarBhattiBlog/~4/LdVhsVZrmUo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://taswar.zeytinsoft.com/2013/02/13/c-perf-improvement-or-using-linq-is-faster/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://taswar.zeytinsoft.com/2013/02/13/c-perf-improvement-or-using-linq-is-faster/</feedburner:origLink></item>
		<item>
		<title>Ubunutu 12.10 installing Scala 2.10 and Play Framework 2.1.0</title>
		<link>http://feedproxy.google.com/~r/TaswarBhattiBlog/~3/yp-Jz1sWWjY/</link>
		<comments>http://taswar.zeytinsoft.com/2013/02/10/ubunutu-12-10-installing-scala-2-10-and-play-framework-2-1-0/#comments</comments>
		<pubDate>Mon, 11 Feb 2013 03:16:06 +0000</pubDate>
		<dc:creator>taswar</dc:creator>
				<category><![CDATA[jvm]]></category>
		<category><![CDATA[playframework]]></category>
		<category><![CDATA[scala]]></category>
		<category><![CDATA[play]]></category>

		<guid isPermaLink="false">http://taswar.zeytinsoft.com/?p=1294</guid>
		<description><![CDATA[First one has to get their java working. To install java ?View Code BASH1 2 3 4 5 6 7 8 9 10 $sudo add-apt-repository ppa:webupd8team/java $sudo apt-get update $sudo apt-get install oracle-java7-installer $sudo update-java-alternatives -s java-7-oracle $which java /usr/bin/java $java -version java version &#34;1.7.0_13&#34; Java&#40;TM&#41; SE Runtime Environment &#40;build 1.7.0_13-b20&#41; Java HotSpot&#40;TM&#41; 64-Bit Server [...]]]></description>
				<content:encoded><![CDATA[<p>First one has to get their java working.</p>
<p>To install java</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1294code12'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p129412"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p1294code12"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$sudo</span> add-apt-repository ppa:webupd8team<span style="color: #000000; font-weight: bold;">/</span>java
<span style="color: #007800;">$sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> update
<span style="color: #007800;">$sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> oracle-java7-installer
<span style="color: #007800;">$sudo</span> update-java-alternatives <span style="color: #660033;">-s</span> java-<span style="color: #000000;">7</span>-oracle
<span style="color: #007800;">$which</span> java
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>java
<span style="color: #007800;">$java</span> <span style="color: #660033;">-version</span>
java version <span style="color: #ff0000;">&quot;1.7.0_13&quot;</span>
Java<span style="color: #7a0874; font-weight: bold;">&#40;</span>TM<span style="color: #7a0874; font-weight: bold;">&#41;</span> SE Runtime Environment <span style="color: #7a0874; font-weight: bold;">&#40;</span>build 1.7.0_13-b20<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Java HotSpot<span style="color: #7a0874; font-weight: bold;">&#40;</span>TM<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000;">64</span>-Bit Server VM <span style="color: #7a0874; font-weight: bold;">&#40;</span>build <span style="color: #000000;">23.7</span>-b01, mixed mode<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></td></tr></table></div>

<p>Once java is installed we will install scala, I like using stow for my package management for non apt-get stuff.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1294code13'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p129413"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p1294code13"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>stow
<span style="color: #007800;">$sudo</span> <span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.scala-lang.org<span style="color: #000000; font-weight: bold;">/</span>downloads<span style="color: #000000; font-weight: bold;">/</span>distrib<span style="color: #000000; font-weight: bold;">/</span>files<span style="color: #000000; font-weight: bold;">/</span>scala-2.10.0.tgz
<span style="color: #007800;">$sudo</span> <span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf scala-2.10.0.tgz
<span style="color: #007800;">$sudo</span> stow scala-2.10.0
<span style="color: #007800;">$which</span> scalac
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>scalac
<span style="color: #007800;">$scalac</span> <span style="color: #660033;">-version</span>
Scala compiler version 2.10.0 <span style="color: #660033;">--</span> Copyright <span style="color: #000000;">2002</span>-<span style="color: #000000;">2012</span>, LAMP<span style="color: #000000; font-weight: bold;">/</span>EPFL</pre></td></tr></table></div>

<p>Now that we have scala is installed lets get play framework installed</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1294code14'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p129414"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code" id="p1294code14"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #007800;">$sudo</span> <span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>downloads.typesafe.com<span style="color: #000000; font-weight: bold;">/</span>play<span style="color: #000000; font-weight: bold;">/</span>2.1.0<span style="color: #000000; font-weight: bold;">/</span>play-2.1.0.zip
<span style="color: #007800;">$sudo</span> <span style="color: #c20cb9; font-weight: bold;">unzip</span> play-2.1.0.zip
<span style="color: #007800;">$cd</span> framework<span style="color: #000000; font-weight: bold;">/</span>sbt<span style="color: #000000; font-weight: bold;">/</span>boot
<span style="color: #007800;">$sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #660033;">-R</span> o+<span style="color: #c20cb9; font-weight: bold;">w</span> boot
<span style="color: #007800;">$vi</span> ~<span style="color: #000000; font-weight: bold;">/</span>.bashrc <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">let</span> add to <span style="color: #007800;">PATH</span>=<span style="color: #007800;">$PATH</span>:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>play-2.1.0:. <span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">$source</span> ~<span style="color: #000000; font-weight: bold;">/</span>.bashrc 
<span style="color: #007800;">$play</span>
      _            _
 _ __ <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">|</span> __ _ _  _<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #ff0000;">'_ \| |/ _'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #000000; font-weight: bold;">|</span>_<span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #000000; font-weight: bold;">|</span>  __<span style="color: #000000; font-weight: bold;">/|</span>_<span style="color: #000000; font-weight: bold;">|</span>\____<span style="color: #000000; font-weight: bold;">|</span>\__ <span style="color: #7a0874; font-weight: bold;">&#40;</span>_<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">|</span>_<span style="color: #000000; font-weight: bold;">|</span>            <span style="color: #000000; font-weight: bold;">|</span>__<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
play<span style="color: #000000; font-weight: bold;">!</span> 2.1.0 <span style="color: #7a0874; font-weight: bold;">&#40;</span>using Java 1.7.0_13 and Scala 2.10.0<span style="color: #7a0874; font-weight: bold;">&#41;</span>, http:<span style="color: #000000; font-weight: bold;">//</span>www.playframework.org
&nbsp;
This is not a play application<span style="color: #000000; font-weight: bold;">!</span>
&nbsp;
Use <span style="color: #000000; font-weight: bold;">`</span>play new<span style="color: #000000; font-weight: bold;">`</span> to create a new Play application <span style="color: #000000; font-weight: bold;">in</span> the current directory,
or go to an existing application and launch the development console using <span style="color: #000000; font-weight: bold;">`</span>play<span style="color: #000000; font-weight: bold;">`</span>.
&nbsp;
You can also browse the <span style="color: #7a0874; font-weight: bold;">complete</span> documentation at http:<span style="color: #000000; font-weight: bold;">//</span>www.playframework.org.</pre></td></tr></table></div>

<p>If you get an error when you launch play that means you havent given the rights to the boot folder, check the commands I have listed above again.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Ftaswar.zeytinsoft.com%2F2013%2F02%2F10%2Fubunutu-12-10-installing-scala-2-10-and-play-framework-2-1-0%2F&amp;title=Ubunutu%2012.10%20installing%20Scala%202.10%20and%20Play%20Framework%202.1.0" id="wpa2a_6"><img src="http://taswar.zeytinsoft.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><img src="http://feeds.feedburner.com/~r/TaswarBhattiBlog/~4/yp-Jz1sWWjY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://taswar.zeytinsoft.com/2013/02/10/ubunutu-12-10-installing-scala-2-10-and-play-framework-2-1-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://taswar.zeytinsoft.com/2013/02/10/ubunutu-12-10-installing-scala-2-10-and-play-framework-2-1-0/</feedburner:origLink></item>
		<item>
		<title>Using LINQ to refactoring code into single responsibility principle SRP</title>
		<link>http://feedproxy.google.com/~r/TaswarBhattiBlog/~3/UiApdC4nics/</link>
		<comments>http://taswar.zeytinsoft.com/2013/01/24/using-linq-to-refactoring-code-into-single-responsibility-principle-srp/#comments</comments>
		<pubDate>Thu, 24 Jan 2013 19:49:21 +0000</pubDate>
		<dc:creator>taswar</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[functional]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[srp]]></category>

		<guid isPermaLink="false">http://taswar.zeytinsoft.com/?p=1280</guid>
		<description><![CDATA[Was going through some legacy code recently and found a big for loop that had multiple switch statement inside. So being that I hate something that is fairly large, every method should be small and concise, I went along to refactor it. This code is generic so you might see something like this in your [...]]]></description>
				<content:encoded><![CDATA[<p>Was going through some legacy code recently and found a big for loop that had multiple switch statement inside. So being that I hate something that is fairly large, every method should be small and concise, I went along to refactor it.</p>
<p>This code is generic so you might see something like this in your code base also.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1280code19'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p128019"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code" id="p1280code19"><pre class="csharp" style="font-family:monospace;">IEnumerable<span style="color: #008000;">&lt;</span>Customer<span style="color: #008000;">&gt;</span> allCustomers <span style="color: #008000;">=</span> Respository<span style="color: #008000;">.</span><span style="color: #0000FF;">GetAllCustomers</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
IDictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span> payingCustomers <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Dictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
IDictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span> nonPayingCustomers <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Dictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
IDictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span> deadBeatCustomers <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Dictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">foreach</span><span style="color: #008000;">&#40;</span>var cust <span style="color: #0600FF; font-weight: bold;">in</span> allCustomers<span style="color: #008000;">&#41;</span> 
<span style="color: #008000;">&#123;</span>
  <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>cust<span style="color: #008000;">.</span><span style="color: #0000FF;">Type</span> <span style="color: #008000;">==</span> IGNORE<span style="color: #008000;">&#41;</span>
    <span style="color: #0600FF; font-weight: bold;">continue</span><span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">switch</span><span style="color: #008000;">&#40;</span>type<span style="color: #008000;">&#41;</span> 
  <span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">case</span> A_TYPE<span style="color: #008000;">:</span> payingCustomer<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>cust<span style="color: #008000;">.</span><span style="color: #0000FF;">Key</span>, cust<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	              <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
	<span style="color: #0600FF; font-weight: bold;">case</span> B_TYPE<span style="color: #008000;">:</span> nonPayingCustomer<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>cust<span style="color: #008000;">.</span><span style="color: #0000FF;">Key</span>, cust<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	              <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
	<span style="color: #0600FF; font-weight: bold;">case</span> C_TYPE<span style="color: #008000;">:</span> deadBeatCustomer<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>cust<span style="color: #008000;">.</span><span style="color: #0000FF;">Key</span>, cust<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	              <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>As you will notice one can go on and keep adding types to it (so did the legacy code).<br />
But if you think about it what this code is basically doing is that its just filtering things out to seperate collections.</p>
<p>Let see how we can answer things with LINQ on this one</p>
<p>First lets remove the if statement for customer IGNORE.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1280code20'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p128020"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p1280code20"><pre class="csharp" style="font-family:monospace;">&nbsp;
<span style="color: #0600FF; font-weight: bold;">foreach</span><span style="color: #008000;">&#40;</span>var cust <span style="color: #0600FF; font-weight: bold;">in</span> allCustomers<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Where</span><span style="color: #008000;">&#40;</span>x <span style="color: #008000;">=&gt;</span> x<span style="color: #008000;">.</span><span style="color: #0000FF;">Type</span> <span style="color: #008000;">!=</span> IGNORE<span style="color: #008000;">&#41;</span> 
<span style="color: #008000;">&#123;</span>  
  <span style="color: #0600FF; font-weight: bold;">switch</span><span style="color: #008000;">&#40;</span>type<span style="color: #008000;">&#41;</span> 
  <span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">case</span> A_TYPE<span style="color: #008000;">:</span> payingCustomer<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>cust<span style="color: #008000;">.</span><span style="color: #0000FF;">Key</span>, cust<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	              <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
	<span style="color: #0600FF; font-weight: bold;">case</span> B_TYPE<span style="color: #008000;">:</span> nonPayingCustomer<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>cust<span style="color: #008000;">.</span><span style="color: #0000FF;">Key</span>, cust<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	              <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
	<span style="color: #0600FF; font-weight: bold;">case</span> C_TYPE<span style="color: #008000;">:</span> deadBeatCustomer<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>cust<span style="color: #008000;">.</span><span style="color: #0000FF;">Key</span>, cust<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	              <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Ok one step done thats better, now lets see that the loop is basically a filter, so lets just take the payingCustomer example and break it down first. Its is going through a loop and finding the A_TYPE customer. Therefore a linq query like</p>
<p><strong>collection.Where(x => x.Type == A_TYPE).toDictionary(t => t.Key, t.Name);</strong></p>
<p>can answer that one.</p>
<p>So lets create a function/method that does this.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1280code21'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p128021"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p1280code21"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> IDictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span> FilterCustomers<span style="color: #008000;">&#40;</span>IEnumerable<span style="color: #008000;">&lt;</span>Customer<span style="color: #008000;">&gt;</span> customers, Type type<span style="color: #008000;">&#41;</span> 
<span style="color: #008000;">&#123;</span>
	<span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>customers <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">throw</span> ArgumentNullException<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	<span style="color: #0600FF; font-weight: bold;">return</span> customers<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Where</span><span style="color: #008000;">&#40;</span>x <span style="color: #008000;">=&gt;</span> x<span style="color: #008000;">.</span><span style="color: #0000FF;">Type</span> <span style="color: #008000;">==</span> type<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">toDictionary</span><span style="color: #008000;">&#40;</span>t <span style="color: #008000;">=&gt;</span> t<span style="color: #008000;">.</span><span style="color: #0000FF;">Key</span>, t<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>So here we have a single responsibility function, that just does one thing and does it well.<br />
Its more of a functional style of programming (data in and data out).<br />
No side effects of any sort. No saving of data to database or file etc.</p>
<p>Now lets go back to our original code, we can now remove the loop and switch statement all together.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1280code22'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p128022"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p1280code22"><pre class="csharp" style="font-family:monospace;">IEnumerable<span style="color: #008000;">&lt;</span>Customer<span style="color: #008000;">&gt;</span> allCustomers <span style="color: #008000;">=</span> Respository<span style="color: #008000;">.</span><span style="color: #0000FF;">GetAllCustomers</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
var filterCustomer <span style="color: #008000;">=</span> allCustomers<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Where</span><span style="color: #008000;">&#40;</span>x <span style="color: #008000;">=&gt;</span> x<span style="color: #008000;">.</span><span style="color: #0000FF;">Type</span> <span style="color: #008000;">!=</span> IGNORE<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
var payingCustomers <span style="color: #008000;">=</span> FilterCustomers<span style="color: #008000;">&#40;</span>filterCustomer, A_TYPE<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
var nonPayingCustomers <span style="color: #008000;">=</span> FilterCustomers<span style="color: #008000;">&#40;</span>filterCustomer, B_TYPE<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
var deadBeatCustomers <span style="color: #008000;">=</span> FilterCustomers<span style="color: #008000;">&#40;</span>filterCustomer, C_TYPE<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>Note: we now have a filterCustomer collection, which filters out the ignore customers first.</p>
<p>By doing so we can write a unit test to test the method/function <strong>FilterCustomers</strong> and we can be 100% sure that all it does is a single responsibility task.<br />
We now have removed complexity in our codebase and the test-ability goes up.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Ftaswar.zeytinsoft.com%2F2013%2F01%2F24%2Fusing-linq-to-refactoring-code-into-single-responsibility-principle-srp%2F&amp;title=Using%20LINQ%20to%20refactoring%20code%20into%20single%20responsibility%20principle%20SRP" id="wpa2a_8"><img src="http://taswar.zeytinsoft.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><img src="http://feeds.feedburner.com/~r/TaswarBhattiBlog/~4/UiApdC4nics" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://taswar.zeytinsoft.com/2013/01/24/using-linq-to-refactoring-code-into-single-responsibility-principle-srp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://taswar.zeytinsoft.com/2013/01/24/using-linq-to-refactoring-code-into-single-responsibility-principle-srp/</feedburner:origLink></item>
		<item>
		<title>Using Linq to refactor code</title>
		<link>http://feedproxy.google.com/~r/TaswarBhattiBlog/~3/r8pdvRzDDL4/</link>
		<comments>http://taswar.zeytinsoft.com/2012/12/17/using-linq-to-refactor-code/#comments</comments>
		<pubDate>Mon, 17 Dec 2012 15:52:59 +0000</pubDate>
		<dc:creator>taswar</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Design]]></category>

		<guid isPermaLink="false">http://taswar.zeytinsoft.com/?p=1269</guid>
		<description><![CDATA[Here is some poorly written code that I had to review today and modify. I have removed the domain of the code and renamed the variables, so that it remains anonymous, but the just of the code is still intact. ?View Code CSHARP1 2 3 4 5 6 7 8 9 10 11 12 13 [...]]]></description>
				<content:encoded><![CDATA[<p>Here is some poorly written code that I had to review today and modify. I have removed the domain of the code and renamed the variables, so that it remains anonymous, but the just of the code is still intact.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1269code27'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p126927"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p1269code27"><pre class="csharp" style="font-family:monospace;">var itemCount <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>users<span style="color: #008000;">.</span><span style="color: #0000FF;">ShoppingCart</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">&amp;&amp;</span> user<span style="color: #008000;">.</span><span style="color: #0000FF;">ShoppingCart</span> <span style="color: #008000;">&gt;</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>var cart <span style="color: #0600FF; font-weight: bold;">in</span> user<span style="color: #008000;">.</span><span style="color: #0000FF;">ShoppingCart</span><span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
   <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>cart<span style="color: #008000;">.</span><span style="color: #0000FF;">Items</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">&amp;&amp;</span> cart<span style="color: #008000;">.</span><span style="color: #0000FF;">Items</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span> <span style="color: #008000;">&gt;</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
     <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>var item <span style="color: #0600FF; font-weight: bold;">in</span> cart<span style="color: #008000;">.</span><span style="color: #0000FF;">Items</span><span style="color: #008000;">&#41;</span>
     <span style="color: #008000;">&#123;</span>
       itemCount<span style="color: #008000;">++;</span>
     <span style="color: #008000;">&#125;</span>
   <span style="color: #008000;">&#125;</span>
  <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Lets go through the inner loop of the code first.</p>
<p>First the loop is really unneccesary one can find out how many items there are using the<br />
count of if since it is an IEnumerable</p>
<p>Thus it becomes</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1269code28'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p126928"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p1269code28"><pre class="csharp" style="font-family:monospace;">var itemCount <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>users<span style="color: #008000;">.</span><span style="color: #0000FF;">ShoppingCart</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">&amp;&amp;</span> user<span style="color: #008000;">.</span><span style="color: #0000FF;">ShoppingCart</span> <span style="color: #008000;">&gt;</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>var cart <span style="color: #0600FF; font-weight: bold;">in</span> user<span style="color: #008000;">.</span><span style="color: #0000FF;">ShoppingCart</span><span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>cart<span style="color: #008000;">.</span><span style="color: #0000FF;">Items</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">&amp;&amp;</span> cart<span style="color: #008000;">.</span><span style="color: #0000FF;">Items</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span> <span style="color: #008000;">&gt;</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
      itemCount <span style="color: #008000;">+=</span> cart<span style="color: #008000;">.</span><span style="color: #0000FF;">Items</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
  <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Now we go to the outer foreach we can put a Where clause to remove the if statement we don&#8217;t really need to check for the &#8220;0&#8243; condition since 1 + 0 is still 1 so why filter for those.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1269code29'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p126929"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p1269code29"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>var cart <span style="color: #0600FF; font-weight: bold;">in</span> user<span style="color: #008000;">.</span><span style="color: #0000FF;">ShoppingCart</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Where</span><span style="color: #008000;">&#40;</span>x <span style="color: #008000;">=&gt;</span> x<span style="color: #008000;">.</span><span style="color: #0000FF;">Items</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>                        
  itemCount <span style="color: #008000;">+=</span> cart<span style="color: #008000;">.</span><span style="color: #0000FF;">Items</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Finally lets remove the entire foreach loop and the count if statement. Since if we have 0 items this code will still not fail.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1269code30'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p126930"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p1269code30"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>users<span style="color: #008000;">.</span><span style="color: #0000FF;">ShoppingCart</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  itemCount <span style="color: #008000;">=</span> users<span style="color: #008000;">.</span><span style="color: #0000FF;">ShoppingCart</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Where</span><span style="color: #008000;">&#40;</span>x <span style="color: #008000;">=&gt;</span> x<span style="color: #008000;">.</span><span style="color: #0000FF;">Items</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Sum</span><span style="color: #008000;">&#40;</span>y <span style="color: #008000;">=&gt;</span> y<span style="color: #008000;">.</span><span style="color: #0000FF;">Items</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Now we have replaced all this code with a linq query that would tell us how many items there are with one line of linq. I believe this makes is easier on the eye and readability of it rather than looping and branching of the code. The more branches you have the harder it is to read code.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Ftaswar.zeytinsoft.com%2F2012%2F12%2F17%2Fusing-linq-to-refactor-code%2F&amp;title=Using%20Linq%20to%20refactor%20code" id="wpa2a_10"><img src="http://taswar.zeytinsoft.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><img src="http://feeds.feedburner.com/~r/TaswarBhattiBlog/~4/r8pdvRzDDL4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://taswar.zeytinsoft.com/2012/12/17/using-linq-to-refactor-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://taswar.zeytinsoft.com/2012/12/17/using-linq-to-refactor-code/</feedburner:origLink></item>
		<item>
		<title>C# detect inuktitut characters Canadian Aboriginal Syllabics</title>
		<link>http://feedproxy.google.com/~r/TaswarBhattiBlog/~3/2TVk-G_QJ14/</link>
		<comments>http://taswar.zeytinsoft.com/2012/11/06/c-detect-inuktitut-characters-canadian-aboriginal-syllabics/#comments</comments>
		<pubDate>Tue, 06 Nov 2012 19:31:32 +0000</pubDate>
		<dc:creator>taswar</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[chsarp]]></category>
		<category><![CDATA[dotnet]]></category>

		<guid isPermaLink="false">http://taswar.zeytinsoft.com/?p=1257</guid>
		<description><![CDATA[Here is a quick way to detect if a text is in Canadian Aboriginal Syllabic in C#. It is just an extension method that would detect if your string is in that range by using regex. ?View Code CSHARP1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 &#160; public [...]]]></description>
				<content:encoded><![CDATA[<p>Here is a quick way to detect if a text is in Canadian Aboriginal Syllabic in C#.</p>
<p>It is just an extension method that would detect if your string is in that range by using regex.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1257code32'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p125732"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code" id="p1257code32"><pre class="csharp" style="font-family:monospace;">&nbsp;
  <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">bool</span> IsInuktitut<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span> <span style="color: #6666cc; font-weight: bold;">string</span> input<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>input<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
            <span style="color: #008080; font-style: italic;">//http://msdn.microsoft.com/en-us/library/20bw873z.aspx</span>
            <span style="color: #008080; font-style: italic;">//look at section  Supported Named Blocks</span>
            <span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">string</span> pattern <span style="color: #008000;">=</span> <span style="color: #666666;">@&quot;\p{IsUnifiedCanadianAboriginalSyllabics}&quot;</span><span style="color: #008000;">;</span>
&nbsp;
            Match match <span style="color: #008000;">=</span> Regex<span style="color: #008000;">.</span><span style="color: #0000FF;">Match</span><span style="color: #008000;">&#40;</span>input, pattern<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">return</span> match<span style="color: #008000;">.</span><span style="color: #0000FF;">Success</span><span style="color: #008000;">;</span>                    
        <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Enjoy.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Ftaswar.zeytinsoft.com%2F2012%2F11%2F06%2Fc-detect-inuktitut-characters-canadian-aboriginal-syllabics%2F&amp;title=C%23%20detect%20inuktitut%20characters%20Canadian%20Aboriginal%20Syllabics" id="wpa2a_12"><img src="http://taswar.zeytinsoft.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><img src="http://feeds.feedburner.com/~r/TaswarBhattiBlog/~4/2TVk-G_QJ14" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://taswar.zeytinsoft.com/2012/11/06/c-detect-inuktitut-characters-canadian-aboriginal-syllabics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://taswar.zeytinsoft.com/2012/11/06/c-detect-inuktitut-characters-canadian-aboriginal-syllabics/</feedburner:origLink></item>
		<item>
		<title>Eclipse Indigo hangs on splash screen workspace</title>
		<link>http://feedproxy.google.com/~r/TaswarBhattiBlog/~3/uzyqr_F-QYc/</link>
		<comments>http://taswar.zeytinsoft.com/2011/12/15/eclipse-indigo-hangs-on-splash-screen-workspace/#comments</comments>
		<pubDate>Thu, 15 Dec 2011 17:20:41 +0000</pubDate>
		<dc:creator>taswar</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://taswar.zeytinsoft.com/?p=1206</guid>
		<description><![CDATA[So today I came in to work and saw that my wonderful windows machine was restarted due to Windows Update, and yesterday I was working on some java stuff and did not close out my eclipse, thank god that I do regular code check-in Anyways tried to relaunch eclipse and it kept hanging on workspace. [...]]]></description>
				<content:encoded><![CDATA[<p>So today I came in to work and saw that my wonderful windows machine was restarted due to Windows Update, and yesterday I was working on some java stuff and did not close out my eclipse, thank god that I do regular code check-in <img src='http://taswar.zeytinsoft.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Anyways tried to relaunch eclipse and it kept hanging on workspace.</p>
<p>To fix that I had to go into my workspace folder C:\workspace\.metadata\.plugins</p>
<p>Then I copied the org.eclipse.core.resources to a backup directory and deleted it from the plugins folder.</p>
<p>I restarted Eclipse and then did a File->Import->Existing Project into Workspace and browse my workspace/project directory</p>
<p>And voila I was back in action <img src='http://taswar.zeytinsoft.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Ftaswar.zeytinsoft.com%2F2011%2F12%2F15%2Feclipse-indigo-hangs-on-splash-screen-workspace%2F&amp;title=Eclipse%20Indigo%20hangs%20on%20splash%20screen%20workspace" id="wpa2a_14"><img src="http://taswar.zeytinsoft.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><img src="http://feeds.feedburner.com/~r/TaswarBhattiBlog/~4/uzyqr_F-QYc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://taswar.zeytinsoft.com/2011/12/15/eclipse-indigo-hangs-on-splash-screen-workspace/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://taswar.zeytinsoft.com/2011/12/15/eclipse-indigo-hangs-on-splash-screen-workspace/</feedburner:origLink></item>
		<item>
		<title>Driving Technical Change Book Review</title>
		<link>http://feedproxy.google.com/~r/TaswarBhattiBlog/~3/w0apYhTE2y8/</link>
		<comments>http://taswar.zeytinsoft.com/2011/10/30/driving-technical-change-book-review/#comments</comments>
		<pubDate>Sun, 30 Oct 2011 20:13:21 +0000</pubDate>
		<dc:creator>taswar</dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[book review]]></category>

		<guid isPermaLink="false">http://taswar.zeytinsoft.com/?p=1198</guid>
		<description><![CDATA[Have wanted to post the review of this book for a while, which I read somewhere beginning of this year. This book does a very good job in classification of the &#8220;typical&#8221; stereotypes of people in IT. - The Uninformed - The Herd - The Cynic - The Burned - The Time Crunched - The [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://taswar.zeytinsoft.com/wp-content/uploads/2011/10/DTC.jpg"><img src="http://taswar.zeytinsoft.com/wp-content/uploads/2011/10/DTC.jpg" alt="Driving Technical Change Book cover" title="Driving Technical Change" width="300" height="300" class="alignleft size-full wp-image-1200" /></a><br />
Have wanted to post the review of this book for a while, which I read somewhere beginning of this year.<br />
This book does a very good job in classification of the &#8220;typical&#8221; stereotypes of people in IT.<br />
- The Uninformed<br />
- The Herd<br />
- The Cynic<br />
- The Burned<br />
- The Time Crunched<br />
- The Boss<br />
- The Irrational </p>
<p>After the first section we go into what kind of techniques we can use to drive technical changes.<br />
- Gain Expertise<br />
- Deliver Your Message<br />
- Demonstrate Your Technique<br />
- Propose Compromise<br />
- Create Trust<br />
- Get Publicity<br />
- Focus on Synergy<br />
- Build a Bridge<br />
- Create Something Compelling</p>
<p>Lastly the author goes into Strategies one can use to drive technical changes<br />
- Simple, Not Easy<br />
- Ignore the Irrational<br />
- Target the Willing<br />
- Harness the Converted<br />
- Sway Management</p>
<p>The book is a short read with only 125 pages, it is a good read but at the same time one should always remember there are people whom you have to deal with that are emotional, and us human&#8217;s are not predictable, the classification helps but if we really want to drive the change we have to be the change agent. I would recommend this book for a beginner who wishes to drive technical changes.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Ftaswar.zeytinsoft.com%2F2011%2F10%2F30%2Fdriving-technical-change-book-review%2F&amp;title=Driving%20Technical%20Change%20Book%20Review" id="wpa2a_16"><img src="http://taswar.zeytinsoft.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><img src="http://feeds.feedburner.com/~r/TaswarBhattiBlog/~4/w0apYhTE2y8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://taswar.zeytinsoft.com/2011/10/30/driving-technical-change-book-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://taswar.zeytinsoft.com/2011/10/30/driving-technical-change-book-review/</feedburner:origLink></item>
		<item>
		<title>JRuby install and build eventmachine from github</title>
		<link>http://feedproxy.google.com/~r/TaswarBhattiBlog/~3/15yv9q7EHYA/</link>
		<comments>http://taswar.zeytinsoft.com/2011/10/21/jruby-install-and-build-eventmachine-from-github/#comments</comments>
		<pubDate>Sat, 22 Oct 2011 03:53:09 +0000</pubDate>
		<dc:creator>taswar</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[eventmachine]]></category>
		<category><![CDATA[Jruby]]></category>

		<guid isPermaLink="false">http://taswar.zeytinsoft.com/?p=1193</guid>
		<description><![CDATA[Have been giving eventmachine a try but I do have issues with it thus wanted to try out the beta version on github. Here is how you get it to install on your local machine. - First clone the repo - Build the gem - Install the java version ?View Code BASH1 2 3 4 [...]]]></description>
				<content:encoded><![CDATA[<p>Have been giving eventmachine a try but I do have issues with it thus wanted to try out the beta version on github.</p>
<p>Here is how you get it to install on your local machine.<br />
- First clone the repo<br />
- Build the gem<br />
- Install the java version</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1193code34'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p119334"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p1193code34"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">git</span> clone <span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>eventmachine<span style="color: #000000; font-weight: bold;">/</span>eventmachine
$ <span style="color: #7a0874; font-weight: bold;">cd</span> eventmachine
$ jruby <span style="color: #660033;">-S</span> gem build eventmachine.gemspec
In this step you might be missing some gems, I was missing yard and rake-compiler
$ jruby <span style="color: #660033;">-S</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> yard
$ jruby <span style="color: #660033;">-S</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> rake-compiler
$ <span style="color: #000000; font-weight: bold;">/</span>c<span style="color: #000000; font-weight: bold;">/</span>jruby-1.6.4<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>rake java gem
 Once the build is <span style="color: #000000; font-weight: bold;">done</span> use the pkg version
$ jruby <span style="color: #660033;">-S</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> pkg<span style="color: #000000; font-weight: bold;">/</span>eventmachine-1.0.0.beta-<span style="color: #000000;">4</span>.java.gem</pre></td></tr></table></div>

<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Ftaswar.zeytinsoft.com%2F2011%2F10%2F21%2Fjruby-install-and-build-eventmachine-from-github%2F&amp;title=JRuby%20install%20and%20build%20eventmachine%20from%20github" id="wpa2a_18"><img src="http://taswar.zeytinsoft.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><img src="http://feeds.feedburner.com/~r/TaswarBhattiBlog/~4/15yv9q7EHYA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://taswar.zeytinsoft.com/2011/10/21/jruby-install-and-build-eventmachine-from-github/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://taswar.zeytinsoft.com/2011/10/21/jruby-install-and-build-eventmachine-from-github/</feedburner:origLink></item>
		<item>
		<title>ERROR: While executing gem … (NameError) uninitialized constant Psych::Syck</title>
		<link>http://feedproxy.google.com/~r/TaswarBhattiBlog/~3/C4ZhimyS8GQ/</link>
		<comments>http://taswar.zeytinsoft.com/2011/10/16/error-while-executing-gem-nameerror-uninitialized-constant-psychsyck/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 02:04:25 +0000</pubDate>
		<dc:creator>taswar</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[goliath]]></category>
		<category><![CDATA[Jruby]]></category>

		<guid isPermaLink="false">http://taswar.zeytinsoft.com/?p=1186</guid>
		<description><![CDATA[What the ???? I was wanting to try out goliath.io (Goliath: Non-blocking, Ruby 1.9 Web Server) for more info look at http://www.igvita.com/2011/03/08/goliath-non-blocking-ruby-19-web-server/ In any case I was not able to get it to install on JRuby so went and get me 1.9.2 MRI. Once installed MRI 1.9.2, I went into the gem dir to gem [...]]]></description>
				<content:encoded><![CDATA[<p>What the ????<br />
I was wanting to try out goliath.io (Goliath: Non-blocking, Ruby 1.9 Web Server) for more info look at <a href="http://www.igvita.com/2011/03/08/goliath-non-blocking-ruby-19-web-server/" title="http://www.igvita.com/2011/03/08/goliath-non-blocking-ruby-19-web-server/">http://www.igvita.com/2011/03/08/goliath-non-blocking-ruby-19-web-server/</a></p>
<p>In any case I was not able to get it to install on JRuby so went and get me 1.9.2 MRI.</p>
<p>Once installed MRI 1.9.2, I went into the gem dir to gem install goliath and guess what this message pops up.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1186code38'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p118638"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1186code38"><pre class="bash" style="font-family:monospace;">ERROR: While executing gem ... <span style="color: #7a0874; font-weight: bold;">&#40;</span>NameError<span style="color: #7a0874; font-weight: bold;">&#41;</span>
uninitialized constant Psych::Syck</pre></td></tr></table></div>

<p>Really helpful (scarcasim) , then what I had to do to fix this was update my gem</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1186code39'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p118639"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1186code39"><pre class="bash" style="font-family:monospace;">gem update <span style="color: #660033;">--system</span></pre></td></tr></table></div>

<p>After doing so I was able to</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1186code40'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p118640"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1186code40"><pre class="bash" style="font-family:monospace;">gem <span style="color: #c20cb9; font-weight: bold;">install</span> goliath</pre></td></tr></table></div>

<p>Now its time to try out goliath, wish me luck and if anyone knows how to install it with Jruby please let me know cuz jgem install goliath didnt work for me.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Ftaswar.zeytinsoft.com%2F2011%2F10%2F16%2Ferror-while-executing-gem-nameerror-uninitialized-constant-psychsyck%2F&amp;title=ERROR%3A%20While%20executing%20gem%20%E2%80%A6%20%28NameError%29%20uninitialized%20constant%20Psych%3A%3ASyck" id="wpa2a_20"><img src="http://taswar.zeytinsoft.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><img src="http://feeds.feedburner.com/~r/TaswarBhattiBlog/~4/C4ZhimyS8GQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://taswar.zeytinsoft.com/2011/10/16/error-while-executing-gem-nameerror-uninitialized-constant-psychsyck/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://taswar.zeytinsoft.com/2011/10/16/error-while-executing-gem-nameerror-uninitialized-constant-psychsyck/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 1.014 seconds. --><!-- Cached page generated by WP-Super-Cache on 2013-06-09 01:34:57 -->
