<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>MagnifierInHand</title><link>http://blogs.msdn.com/b/magnifierinhand/</link><description /><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>How to Review for the Open/Closed Principle</title><link>http://blogs.msdn.com/b/magnifierinhand/archive/2013/04/25/how-to-review-for-the-open-closed-principle.aspx</link><pubDate>Thu, 25 Apr 2013 17:55:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10414033</guid><dc:creator>Alfredo_Alvarez</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/magnifierinhand/rsscomments.aspx?WeblogPostID=10414033</wfw:commentRss><comments>http://blogs.msdn.com/b/magnifierinhand/archive/2013/04/25/how-to-review-for-the-open-closed-principle.aspx#comments</comments><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;What is the open/closed principle should be the first&lt;br /&gt;question we ask. It states that an entity in a system should be open for&lt;br /&gt;extension and closed for modification.&amp;nbsp;&lt;br /&gt;In terms of C# what it means to us is that a class should only be&lt;br /&gt;modified if a bug is found on it. The rest of the time when we are doing new&lt;br /&gt;functionality we should create a new class.&lt;/p&gt;
&lt;p&gt;For functionality that is related it implies that we inherit&lt;br /&gt;from the original object.&amp;nbsp; In terms of&lt;br /&gt;this post the idea is to detect the conditions in which the code in question is&lt;br /&gt;either breaking this principle or it will affect people trying to follow it on&lt;br /&gt;the future. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Which bring us to the followings which elements do we need to look at to&lt;br /&gt;determine how will affect the people in the future?&lt;/p&gt;
&lt;h1&gt;How does Open/Closed affect test efforts?&lt;/h1&gt;
&lt;p&gt;When a project does not follow this principle during&lt;br /&gt;execution it ends up impacting the test surface and the amount of regression&lt;br /&gt;needed.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s consider the following application:&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s a web service it takes a small piece of xml with two values&lt;br /&gt;and operation that will be done to it &amp;nbsp;brings back a result.&lt;/p&gt;
&lt;p&gt;On the first iteration they created it with the&lt;br /&gt;functionality for adding since it was all that was needed.&lt;/p&gt;
&lt;p&gt;It looked something similar to this:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;table border="1" cellspacing="0" cellpadding="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="623"&gt;
&lt;p&gt;Public class MathOperations()&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; Public long&lt;br /&gt;&amp;nbsp; GetOperationResult(string xml)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Int result=;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp; This.Logger.StartOperationLog(parser.operand1, parser.operand2,&lt;br /&gt;&amp;nbsp; parser.symbol);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Var parser = new&lt;br /&gt;&amp;nbsp; OperationParser(xml);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If(parser.symbol ==&lt;br /&gt;&amp;nbsp; &amp;rdquo;+&amp;rdquo;)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;{&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result =&lt;br /&gt;&amp;nbsp; parser.operand1 + parser.operand2;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp; This.Logger.EndOperationLog(parser.operand1, parser.operand2,&lt;br /&gt;&amp;nbsp; parser.symbol);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return result&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;In the implementation above if you think about adding the other 3 operations&lt;br /&gt;for your second sprint would require to ensure that everything works once again&lt;br /&gt;since changes in the main file might affect the processing of the add&lt;br /&gt;operation.&amp;nbsp; How can we make this class&lt;br /&gt;apply the principle and make it only impact the operation execution on our test?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;One possible way to do it&amp;rsquo;s to write the original class&lt;br /&gt;using a factory therefore adding next operations means that only a new class&lt;br /&gt;gets added into this project and only the new class needs to be tested.&lt;/p&gt;
&lt;p&gt;It would look something similar to below.&lt;/p&gt;
&lt;table border="1" cellspacing="0" cellpadding="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="623"&gt;
&lt;p&gt;Public class MathOperations()&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; Public long&lt;br /&gt;&amp;nbsp; GetOperationResult(string xml)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Int result=;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp; This.Logger.StartOperationLog(parser.operand1, parser.operand2,&lt;br /&gt;&amp;nbsp; parser.symbol);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Var parser = new&lt;br /&gt;&amp;nbsp; OperationParser(xml);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result =&lt;br /&gt;&amp;nbsp; OperationFactory.GetInstance(parser).DoOperation();&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp; This.Logger.EndOperationLog(parser.operand1, parser.operand2,&lt;br /&gt;&amp;nbsp; parser.symbol);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return result&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;It means that after sprint one all the test you did for mathoperations would&lt;br /&gt;still apply and not really need to be executed again.&lt;/p&gt;
&lt;p&gt;On the next post I&amp;rsquo;m going to describe how to find out if&lt;br /&gt;your team actually adheres to this principles and what are things that can tell&lt;br /&gt;you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10414033" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/magnifierinhand/archive/tags/code+review/">code review</category><category domain="http://blogs.msdn.com/b/magnifierinhand/archive/tags/MSIT/">MSIT</category><category domain="http://blogs.msdn.com/b/magnifierinhand/archive/tags/SDET/">SDET</category><category domain="http://blogs.msdn.com/b/magnifierinhand/archive/tags/patterns/">patterns</category></item><item><title>Code Review: How to improve your personal technique</title><link>http://blogs.msdn.com/b/magnifierinhand/archive/2012/11/12/code-review-how-to-improve-your-personal-technique.aspx</link><pubDate>Mon, 12 Nov 2012 18:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10367837</guid><dc:creator>Alfredo_Alvarez</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/magnifierinhand/rsscomments.aspx?WeblogPostID=10367837</wfw:commentRss><comments>http://blogs.msdn.com/b/magnifierinhand/archive/2012/11/12/code-review-how-to-improve-your-personal-technique.aspx#comments</comments><description>&lt;p&gt;Last time here besides saying hello we talked about how to be helpful&amp;nbsp;during a&amp;nbsp;code review at any skill level. We showed the different levels of help that can be provided. On this post&amp;nbsp;I want to describe techniques in order to ascend the piramid and increase the accuracy of your review.&lt;/p&gt;
&lt;p&gt;So what can we do to improve on each level.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Readibility, Tracing and Support&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;To&amp;nbsp; improve on readibility Read Code Complete, Read Clean Code, Read the comment on peers code review to see what they are looking for read only a few code guidelines and look at the points that get argued.&lt;/li&gt;
&lt;li&gt;To improve application Tracing and support - Talk with whoever runs your application and see what pain points are directly related to missing traces or ids. Write a checklist on the next code review make a checklist of it.&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;Reliability and Testability&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;One possibility is to read &lt;span id="btAsinTitle"&gt;Reengineering .NET: Injecting Quality, Testability, and Architecture into Existing Systems.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Make a map of things you would need to disconnect a particular service see if it does.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Review all retry loops and make sure that their behaviour is reasonable.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;Performance, Security And Concurrency&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;On the Performance part reading CLRS and doing the exercises and Programming pearls will help. Imagine how it would perform if the code did things differently and compare feel free to discuss alternatives.&lt;/li&gt;
&lt;li&gt;For security participate on the thread model of your application keep it in hand when doing the review to see what are the vectors on this specific code. Follow &lt;a href="http://msdn.microsoft.com/en-us/library/ff648189.aspx"&gt;http://msdn.microsoft.com/en-us/library/ff648189.aspx&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Concurrency -&amp;gt; Read about threading model in .net &lt;a href="http://msdn.microsoft.com/en-US/library/ms173178(v=VS.80).aspx"&gt;http://msdn.microsoft.com/en-US/library/ms173178(v=VS.80).aspx&lt;/a&gt; learn about the sync async model and how it works on the background.&amp;nbsp; Use paper to try and draw small parts that work concurrently and see if they would have problem accessing resources. Compare with the code at hand.&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;Software Design&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;A book on design patterns, I would say read emergent design.&lt;/li&gt;
&lt;li&gt;Code a few application trying the different patterns to see why are they useful.&lt;/li&gt;
&lt;li&gt;Read on Frameworks dependency injection and flow control(MVC, MVVM)&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;p&gt;One thing that applies to all levels&amp;nbsp;is participate in a more varied amount of code reviews one suggestion if your work allows is oss projects and &lt;a href="http://codereview.stackexchange.com/"&gt;http://codereview.stackexchange.com/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Hope this helps for the next post i plan to start writing down real world examples of code review situations and go tru them explaining the reason of why each one is a problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10367837" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/magnifierinhand/archive/tags/code+review/">code review</category><category domain="http://blogs.msdn.com/b/magnifierinhand/archive/tags/self+improvement/">self improvement</category></item><item><title>New role: new blog</title><link>http://blogs.msdn.com/b/magnifierinhand/archive/2012/10/15/new-role-new-blog.aspx</link><pubDate>Mon, 15 Oct 2012 00:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10359530</guid><dc:creator>Alfredo_Alvarez</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/magnifierinhand/rsscomments.aspx?WeblogPostID=10359530</wfw:commentRss><comments>http://blogs.msdn.com/b/magnifierinhand/archive/2012/10/15/new-role-new-blog.aspx#comments</comments><description>&lt;p&gt;Welcome to &lt;a title="http://blogs.msdn.com/b/magnifierinhand/" href="http://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/Magnifier in Hand"&gt;Magnifier in Hand&lt;/a&gt;, where&amp;nbsp;I will be posting about being an SDET and their interactions with&amp;nbsp;the software process.&lt;/p&gt;
&lt;p&gt;You' re probably wondering, who is this guy? What qualifies him to be talking here?&lt;/p&gt;
&lt;p&gt;Well, let me take the time to&amp;nbsp;answer both of those questions.&amp;nbsp;Currently,&amp;nbsp;I'm a SDET on the PSIT group in MSIT. Prior to this role,&amp;nbsp;I&amp;nbsp; was a Developer for&amp;nbsp;4 years&amp;nbsp;at Microsoft. I changed&amp;nbsp;positions about 4 months ago and I'm currently exploring this new field and hoping to share my findings. If you want more information&amp;nbsp;about&amp;nbsp;my&amp;nbsp;previous&amp;nbsp;experience,&amp;nbsp;here is a link to&lt;a href="http://alfredoalvarez.com/blog/"&gt; my old blog&lt;/a&gt;&amp;nbsp;.&lt;/p&gt;
&lt;p&gt;Alright, so let's get things rolling.&amp;nbsp;My team&amp;nbsp;has been implementing the practice full team code review. Therefore this is the first topic that&amp;nbsp;I want to discuss (topics&amp;nbsp;about code review will be&amp;nbsp;discussed from now till the end of March). While a lot of my co-workers have asked me for examples of what to look for&amp;nbsp;in code reviews, I'm going to start with the other&amp;nbsp;most frequently&amp;nbsp;asked question which is the following; How can&amp;nbsp;I be helpful in the code review process if my coding skills are not as good as&amp;nbsp;the developers?&lt;/p&gt;
&lt;p&gt;The answer is the following:&amp;nbsp;anyone can be helpful in a code review as long as&amp;nbsp;he or she&amp;nbsp;person has basic proficiency with the language at hand.&amp;nbsp;I have made&amp;nbsp;the following&amp;nbsp;diagram to help assess&amp;nbsp;your skill level&amp;nbsp;and determine how&amp;nbsp;helpful you will be in the process.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-49/7853.Code-Review.png"&gt;&lt;img border="0" alt="" src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-49/7853.Code-Review.png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;On my next blog post I'm going to cover what steps&amp;nbsp;can be taken&amp;nbsp;to increase your value as a reviewer and&amp;nbsp;move up in this diagram.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10359530" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/magnifierinhand/archive/tags/code+review/">code review</category><category domain="http://blogs.msdn.com/b/magnifierinhand/archive/tags/MSIT/">MSIT</category><category domain="http://blogs.msdn.com/b/magnifierinhand/archive/tags/SDET/">SDET</category></item></channel></rss>