<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Quality Software Matters]]></title><description><![CDATA[Quality Software Matters]]></description><link>https://qualitysoftwarematters.com</link><generator>RSS for Node</generator><lastBuildDate>Sun, 17 May 2026 21:18:12 GMT</lastBuildDate><atom:link href="https://qualitysoftwarematters.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[The Coding Dojo]]></title><description><![CDATA[In my post on "Being Prepared", I wrote about the need for us to practice our craft in order to deliver high quality code.  Unfortunately, there are a lot of demands for our time working on projects that are under tight deadlines and supporting exist...]]></description><link>https://qualitysoftwarematters.com/the-coding-dojo</link><guid isPermaLink="true">https://qualitysoftwarematters.com/the-coding-dojo</guid><dc:creator><![CDATA[Todd Meinershagen]]></dc:creator><pubDate>Thu, 13 Aug 2015 05:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1683415803607/6a0fb157-4aff-4f99-8a5e-dd9bab409552.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In <a target="_blank" href="http://www.qualitysoftwarematters.com/2015/07/being-prepared.html">my post on "Being Prepared"</a>, I wrote about the need for us to <strong><em>practice</em></strong> our craft in order to deliver high quality code.  Unfortunately, there are a lot of demands for our time working on projects that are under tight deadlines and supporting existing software in production.</p>
<p>One of the ways to escape the daily grind and focus on developing new skills is to participate in a <strong><em>coding dojo</em></strong>.</p>
<h2 id="heading-what-is-a-coding-dojo">What is a Coding Dojo?</h2>
<blockquote>
<p>In software we do our practicing on the job, and
that’s why we make mistakes on the job. We need
to find ways of splitting the practice from the profession.
We need practice sessions.</p>
</blockquote>
<p><strong>-Dave Thomas</strong></p>
<p>A coding dojo is a periodic meeting where developers <strong><em>practice</em></strong> the craft of coding together with the object of learning how to do it better.  The discussion should center around design, testing, refactoring, and tools.</p>
<h2 id="heading-safe-environment">Safe Environment</h2>
<blockquote>
<p>Safety doesn't happen by accident</p>
</blockquote>
<p><strong>-Author Unknown</strong></p>
<p>Creating a safe environment is not a given.  The facilitator of a coding dojo is responsible for establishing the tone by delivering an intro explaining the objective of the meeting and reminding the team that it is okay to not know something and ask questions. </p>
<p>Each session should have a clear objective or focus and any code produced is purely for practice and should not be leveraged for real production software.  It's this aspect of throw away code that allows coders to feel safe to experiment and possibly fail while obtaining a higher level of skill.</p>
<p>Should managers be there?</p>
<p>I don't recommend that managers attend this meeting, since it is a place for actual hands-on coders to code with each other.  Having participants that are merely observing or making comments without being involved with the coding might ignite a spirit of fear which would be detrimental to the learning process.</p>
<p>If there are hands-on managers that want to learn and code along with the team, then the team can decide whether or not to allow it.</p>
<h2 id="heading-retrospectivereflection">Retrospective/Reflection</h2>
<blockquote>
<p>Follow effective action with quiet reflection.  From the quiet reflection will come even more effective action.</p>
</blockquote>
<p><strong>-Peter Drucker</strong></p>
<p>Just as in any empirical process, it is important to step back and reflect on how well things are going at the end of the session.  This will allow the team to inspect their progress and adapt.  Make sure to give at least 10-15 minutes for this retrospective and come away with at most 1-2 action items for the next meeting.  It is also important to recognize and document the principles that the team learns during the session.</p>
<h2 id="heading-test-driven">Test-Driven</h2>
<blockquote>
<p>Feedback is the breakfast of champions.</p>
</blockquote>
<p><strong>-Ken Blanchard</strong></p>
<p>Another essential component to any dojo is the practice of writing tests in addition to the code.  These will provide feedback to participants to ensure that code works as expected.</p>
<h2 id="heading-show-working">Show working</h2>
<blockquote>
<p>The end cannot justify the means, for the simple and obvious reason that the means employed determine the nature of the ends produced.</p>
</blockquote>
<p><strong>-Aldous Huxley</strong></p>
<p>Another important principle is to demonstrate how you write code - not just showing the final result of the code that you produce.  The process or means is much more important than the product or the ends.  This will ensure that the team learns the mechanisms for writing good code and not just what good code looks like.  </p>
<p>This is very similar to the concept of learning by doing.  </p>
<p>Which do you learn from more - reviewing someone's code in source control or pairing with that person to see how they produced it?  How about listening to an instructor teach for hours or actually doing a lab under their supervision?</p>
<h2 id="heading-frequency">Frequency</h2>
<blockquote>
<p>If it hurts, do it more often.</p>
</blockquote>
<p><strong>-Jez Humble</strong></p>
<p>How often should coding dojos meet?  </p>
<p>There is no hard and fast rule to answer this question.  But keep in mind that if you don't do it often enough (weekly or bi-weekly) you might not make much progress and members may become disillusioned with the process.  And whatever interval the team chooses, make sure to keep it consistent so that people are willing to commit and look forward to the meetings .</p>
<h2 id="heading-content">Content</h2>
<p>What should be the content of any given session?</p>
<p>We will discuss this topic in more detail in another post, but to begin with, consider working on a simple algorithmic problem in a tool of the team's choosing.  So, for example, you might implement the <a target="_blank" href="http://www.butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata">Prime Factors algorithm</a> using JavaScript.  Or, you might want to implement the <a target="_blank" href="http://c2.com/cgi/wiki?FizzBuzzTest">FizzBuzz algorithm</a> using C#.</p>
]]></content:encoded></item><item><title><![CDATA[Application Monitoring]]></title><description><![CDATA[Do you actively monitor your applications?
Chances are that if your development team doesn't, your operations group does. There are a variety of metrics that they are watching at a high level like CPU and memory usage performance counters and whether...]]></description><link>https://qualitysoftwarematters.com/application-monitoring</link><guid isPermaLink="true">https://qualitysoftwarematters.com/application-monitoring</guid><dc:creator><![CDATA[Todd Meinershagen]]></dc:creator><pubDate>Sat, 18 Jul 2015 05:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1683415800062/f9d1fd23-bd0f-425c-aa87-5c85724f4398.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Do you actively monitor your applications?</p>
<p>Chances are that if your development team doesn't, your operations group does. There are a variety of metrics that they are watching at a high level like CPU and memory usage performance counters and whether or not your applications and services are up or down. These help them to know whether or not there is trouble on the rise or if it has already arrived.</p>
<p>The alternative is to not monitor your applications and wait until something fails. The risk of the "wait-and-see" approach is much greater, however, because the stress and cost of fixing the issue may be high.</p>
<h2 id="heading-monitoring-in-other-domains">Monitoring in Other Domains</h2>
<p>Application monitoring reminds me of the data-centric direction that healthcare is moving. In a <a target="_blank" href="http://traffic.libsyn.com/timferriss/Tim_Ferriss_Show_-_Peter_Diamandis_QnA_LegalZoom_1.mp3">podcast I heard recently with Peter Diamandis</a>, he mentions that we will be seeing more and more bio-metric sensors that we can wear, ingest, or inject below our skin that constantly monitor what we eat and breath and our health levels such as glucose. Instead of waiting to deal with a problem that has become visible either to the naked eye or our sense of pain with critical care, we will be able to leverage preventative maintenance when conditions indicate that a problem is on the horizon.</p>
<p>This is very similar to the airline industry in which airplane engines are already equipped with hundreds of sensors that can indicate when anything is out of the norm, and when identified, immediately move the airplane into service mode for maintenance.</p>
<p>Most of our applications are not dealing with life and death consequences when they fail, but it is still vitally important to monitor our applications to sense when something is out of the norm so that we can prevent future issues.</p>
<h2 id="heading-transaction-monitoring">Transaction Monitoring</h2>
<p>Most monitoring is at a very high level and does not expose the kind of application details that a development group might be more interested at the transaction level. For each type of transaction, you may be interested in knowing the following metrics for a given time period:</p>
<ul>
<li><h1 id="heading-of-successful-transactions">of Successful Transactions</h1>
</li>
<li><h1 id="heading-of-failed-transactions">of Failed Transactions</h1>
</li>
<li><p>Average Execution Time for a Transaction</p>
</li>
</ul>
<p>This kind of information would help development teams to know if their applications or any third party dependencies inside or outside of the organization are performing at expected or contractually agreed upon levels (service level agreements) for different types of transactions within the application.</p>
<p>Unfortunately, this kind of data is not automatically emitted from your applications as performance counters. It requires some custom code.</p>
<h2 id="heading-jamesdiagnostics">James.Diagnostics</h2>
<p>I have released a new .NET library (<a target="_blank" href="https://www.nuget.org/packages/James.Diagnostics/">James.Diagnostics</a>) on NuGet.org that can make the set up and use of these counters relatively simple compared to the out-of-the-box method that Microsoft has provided. (If any of you have tried creating custom performance counters, you will know what I mean.)</p>
<p><a target="_blank" href="https://www.nuget.org/packages/James.Diagnostics/">James.Diagnostics</a> is a convention-based library built on top of <a target="_blank" href="https://www.nuget.org/packages/Magnum/">Magnum</a> to help you to add custom performance counters to your existing applications. It is based on the assumption that in most cases you will want to instrument your application logic for:</p>
<ul>
<li><p>Successes</p>
</li>
<li><p>Failures</p>
</li>
<li><p>Average Execution Times</p>
</li>
</ul>
<p>If you need other types of custom counters, libraries such as <a target="_blank" href="https://www.nuget.org/packages/Magnum/">Magnum</a>, written by Chris Patterson and Dru Sellers, can help you. If you are interested in reviewing the <a target="_blank" href="https://github.com/QualitySoftwareMatters/James.Diagnostics">source code</a> or contributing, you can find it <a target="_blank" href="https://github.com/QualitySoftwareMatters/James.Diagnostics">here</a>.</p>
<h2 id="heading-installing-the-library">Installing the Library</h2>
<p>From the package manager console in Visual Studio, you can enter the following:</p>
<p><code>&gt; install-package James.Diagnostics</code></p>
<h2 id="heading-creating-performance-counters">Creating Performance Counters</h2>
<p>Let's say you have a service that allows clients to get and update customer information.</p>
<pre><code class="lang-csharp"><span class="hljs-function"><span class="hljs-keyword">public</span> IEnumerable <span class="hljs-title">GetCustomers</span>(<span class="hljs-params"></span>)</span>
{
    <span class="hljs-keyword">return</span> _repository.GetAll();
}

<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">UpdateCustomer</span>(<span class="hljs-params">Customer customer</span>)</span>
{
    _repository.Update(customer);
}
</code></pre>
<p>Creating custom performance counters for these two methods is as simple as inheriting CounterCategory and implementing the IMonitorableCounterCategory for each as shown below.</p>
<pre><code class="lang-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">CustomerService_GetCustomersCounters</span> 
    : <span class="hljs-title">CounterCategory</span>, <span class="hljs-title">IMonitorableCounterCategory</span>
{
  <span class="hljs-keyword">public</span> Counter Succeeded { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; }
  <span class="hljs-keyword">public</span> Counter Failed { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; }
  <span class="hljs-keyword">public</span> Counter ExecutionTime { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; }
}

<span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">CustomerService_UpdateCustomerCounters</span> 
    : <span class="hljs-title">CounterCategory</span>, <span class="hljs-title">IMonitorableCounterCategory</span>
{
  <span class="hljs-keyword">public</span> Counter Succeeded { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; }
  <span class="hljs-keyword">public</span> Counter Failed { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; }
  <span class="hljs-keyword">public</span> Counter ExecutionTime { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; }
}
</code></pre>
<p>Once you have these in place, you can begin to use those to <code>Monitor()</code> your methods.</p>
<pre><code class="lang-csharp"><span class="hljs-function"><span class="hljs-keyword">public</span> IEnumerable <span class="hljs-title">GetCustomers</span>(<span class="hljs-params"></span>)</span>
{
    <span class="hljs-keyword">return</span> Monitoring&lt;CustomerService_GetCustomerCounters&gt;.Monitor(() =&gt; _repository.GetAll());
}

<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">UpdateCustomer</span>(<span class="hljs-params">Customer customer</span>)</span>
{
    Monitoring&lt;CustomerService_UpdateCustomerCounters&gt;.Monitor(() =&gt; _repository.Update(customer));
}
</code></pre>
<p>Below is a sample screenshot of Performance Monitor showing one of these performance counter categories in action. In the graph there are three colored lines representing the three counters.</p>
<ul>
<li><p><strong>Blue Line</strong> - represents the execution times in milliseconds.</p>
</li>
<li><p><strong>Green Line</strong> - represents the number of successes.</p>
</li>
<li><p><strong>Red Line</strong> - represents the number of failures.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683415798609/9d2b2551-6f87-4c31-a1f7-5ff202b48fee.png" alt="capture-perfmon-james-diagnostics" /></p>
<p>If these metrics are brought into tools such as SCOM, they can be further manipulated to derive computed metrics such as the percentage of successes or average execution times aggregated by time periods.</p>
<h2 id="heading-synchronous-monitoring-options">Synchronous Monitoring Options</h2>
<p>There are multiple options for monitoring the execution of your synchronous code with custom performance counters.</p>
<h3 id="heading-void-monitoraction-action">void Monitor(Action action)</h3>
<hr />
<p>Takes an action and increments the success/failure counters depending on whether or not the action succeeds (ie. - does not throw). If an exception does occur, it will bubble this up.</p>
<h3 id="heading-t-monitorandlttandgtfuncandlttandgt-function">T Monitor&lt;T&gt;(Func&lt;T&gt; function)</h3>
<hr />
<p>Takes a function and increments the success/failure counters depending on whether or not the action succeeds (ie. -does not throw). If an exception does occur, it will bubble this up. If it succeeds, it will also return the result of the function call.</p>
<h3 id="heading-void-monitorfuncandltboolandgt-function">void Monitor(Func&lt;bool&gt; function)</h3>
<hr />
<p>Takes a function that returns a true/false and increments the success/failure counters depending on whether or not the function returns a true or false. It will not return the boolean value to the client, however. So, only use this method if you are instrumenting something that gracefully handles exceptions by not bubbling them up.</p>
<h2 id="heading-asynchronous-monitoring-options">Asynchronous Monitoring Options</h2>
<p>Sometimes, the distance between beginning and ending your monitoring is not just in time but also by process or machine. This often occurs in distributed systems (especially messaging) where the process that you would like to instrument occurs on one machine or process and ends in another. James.Diagnostics has you covered in these scenarios.</p>
<h3 id="heading-process-1-sending-message">Process 1: Sending Message</h3>
<pre><code class="lang-csharp"><span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">SendMessage</span>(<span class="hljs-params">Customer customer</span>)</span>
{
    <span class="hljs-keyword">var</span> message = <span class="hljs-keyword">new</span> CustomerUpdate
        {  
            Customer = Customer, 
            Success = <span class="hljs-literal">true</span>,
            Start = DateTime.Now.ToUniversalTime()
        };

    _bus.Publish(message);
}
</code></pre>
<h3 id="heading-process-2-consuming-message">Process 2: Consuming Message</h3>
<pre><code class="lang-csharp"><span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">Consume</span>(<span class="hljs-params">CustomerUpdate message</span>)</span>
{
    <span class="hljs-keyword">var</span> elapsed = DateTime.Now.ToUniversalTime().Subtract(message.Start);
    message.Success 
        ? Monitoring&lt;CustomerService_CustomerUpdatedCounters&gt;.Success(elapsed)
        : Monitoring&lt;CustomerService_CustomerUpdatedCounters&gt;.Failure();
}
</code></pre>
<p>You will notice that in the case of the <code>Failure()</code> method, there is no <code>TimeSpan</code> to be provided. This is because a failure will either happen immediately or due to timeout, may be very lengthy. In either situation, you will not want to skew your average execution time metrics.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Whatever approach you choose to take, emitting transaction-level metrics are an important piece you should add to any of your applications to provide more insight. If you do try out <a target="_blank" href="https://www.nuget.org/packages/James.Diagnostics/">James.Diagnostics</a>, let me know. And any feedback you provide will be appreciated.</p>
<p>Hope it helps!</p>
]]></content:encoded></item><item><title><![CDATA[Quality is Everyone's Responsibility]]></title><description><![CDATA[Have you ever had this experience before?

I drove up to a Chase ATM to transfer money from my Liquid account (re-loadable debit card we use for budgeting purposes) to our main checking account.  (I know - it would be nice if I could just transfer th...]]></description><link>https://qualitysoftwarematters.com/quality-is-everyones-responsibility</link><guid isPermaLink="true">https://qualitysoftwarematters.com/quality-is-everyones-responsibility</guid><dc:creator><![CDATA[Todd Meinershagen]]></dc:creator><pubDate>Thu, 09 Jul 2015 05:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1683415792698/4fdfd763-76a1-40ea-9177-97fd83b58df3.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Have you ever had this experience before?</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683415792698/4fdfd763-76a1-40ea-9177-97fd83b58df3.jpeg" alt="chase-atm-cash" /></p>
<p>I drove up to a Chase ATM to transfer money from my Liquid account (re-loadable debit card we use for budgeting purposes) to our main checking account.  (I know - it would be nice if I could just transfer this stuff online.  Unfortunately, the Liquid account does not allow direct online transfers.)  </p>
<p>First, I withdrew the $180 in the usual denomination of $20 bills.  Then, I tried to deposit the same cash back into our main checking account.  I waited for a few seconds while the machine chewed on my money and decided to spit out a $20 bill that it couldn't accept - something to do with the validity of the bill.  Of course, I tried multiple times unsuccessfully, hoping each time to pass the validity check, but instead found that this darn machine wouldn't accept it's own cash!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683415794319/04e47836-b554-4612-ac96-faa439114dc8.jpeg" alt="chase-long-line" /></p>
<p>So, I finally drove up to the bank parking lot and rushed into the lobby to find a line of 8 customers waiting to be served.  Things are not looking good at this point for a quick transfer of cash.  So, I go back outside and speed my car to the Chase business checking drive-through.  I impatiently explain my quandary to the attendant.</p>
<p>"Your ATM machine doesn't seem to want to accept cash that I received as a withdrawal from another account.  I don't know what the problem is.  Can you help me?"</p>
<p>She curtly took my $20 bill and ATM card (presumably because I am not a business customer) and deposited the money directly for me.  And when she came back to the microphone, she looked at me through the window and explained that while she was sorry for the mishap, the ATM machine belongs to another company and that they are looking to replace it soon. I said thanks and drove away a little confused.  </p>
<p>Exactly what does that mean that the ATM machine is not theirs?  It had their logo on it, and the software clearly displayed their brand name in its wizard to withdraw and deposit my cash.  </p>
<p>How is that supposed to be a comfort to me as a frustrated consumer?  All I care about is getting my money transferred quickly.</p>
<p>However, this incident got me thinking about how the same kind of thing can occur as we support our own software products and services.  </p>
<p>It's easy for the internal and external teams that develop and support the software to blame each other to the customer for what caused a business critical incident.  And there's plenty of reasons why.</p>
<p>Maybe a Windows Update patch to your servers caused your Windows service not to restart, leaving your customers high and dry.  Or maybe one of the nodes in your web cluster went down and the health check that should have signaled your load balancer to redirect traffic to another node didn't work.  Or maybe the third party service you use for some feature didn't live up to their service level agreements and were down during a critical time.  Or maybe the Product Owner didn't understand what was best for their customer and had the team create a feature that just doesn't find acceptance with them.</p>
<p>Whatever the reason for the failure, from the customer's perspective the product doesn't work.  And getting the problem resolved quickly should be the first order of business.  </p>
<p>It's not one particular group that is ultimately responsible.  Because when customers use our software, they only see one, unified product.  They don't understand the intricacies of how and why a problem occurred.  They only care that the problem occurred and that it needs to be fixed.</p>
<p>There will be time to get to the bottom of the root cause and figure out how to avoid it in the future, but for now, quality shows in how quickly you can respond and fix your customer's issues.  So, anything that you can do to make that process smooth and easy is recommended.  </p>
<p>So, think through what kinds of information your application should be emitting when trouble strikes and make sure that you have the proper tools, access, and support that you need to get to the bottom of an issue and enhance your application's maintainability.</p>
<p>And remember that quality is everyone's responsibility.</p>
]]></content:encoded></item><item><title><![CDATA[Being Prepared]]></title><description><![CDATA[It happens every once in a while.  
I waltz into the classroom looking forward to a new lesson and suddenly realize that today is the final exam.  Everything I should have been preparing for is finally due.  And I haven't done anything -- no flash ca...]]></description><link>https://qualitysoftwarematters.com/being-prepared</link><guid isPermaLink="true">https://qualitysoftwarematters.com/being-prepared</guid><dc:creator><![CDATA[Todd Meinershagen]]></dc:creator><pubDate>Thu, 02 Jul 2015 05:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1683415788691/6f07e6c4-7392-4a42-8d50-e194e8a1efcb.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>It happens every once in a while.  </p>
<p>I waltz into the classroom looking forward to a new lesson and suddenly realize that today is the final exam.  Everything I should have been preparing for is finally due.  And I haven't done anything -- no flash cards, no notes, no readings, no late night, caffeine-infested sessions the night before.  In fact, I can't remember if I have attended any of the prior classes.  </p>
<p>As I begin to panic and look for an excuse to leave and make up the exam later, I wake up.  It was all a dream - or a nightmare!  It takes a few seconds, but I finally realize that nothing that I was experiencing is actually true.  What a relief!</p>
<h2 id="heading-how-about-you">How About You?</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683415786178/bbd10575-5685-4212-ad6e-e6968695390f.png" alt="A Man with His Toolbelt" /></p>
<p>But how many of us come to work unprepared each day?  </p>
<p>I mean -- how well do we know our tools?  </p>
<p>Do we know all of the ins and outs of our particular language, platform, tools, and techniques?  </p>
<p>Or do we only know those parts that we had to use for our latest project?  </p>
<p>Or do we only understand the basic "Hello, world" features that we learned from reading a blog, listening to a podcast, or attending a conference session?</p>
<h2 id="heading-being-a-passionate-programmer">Being a Passionate Programmer</h2>
<p>This question came up in a book, <a target="_blank" href="http://www.amazon.com/gp/product/1934356344/ref=as_li_tl?ie=UTF8&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1934356344&amp;linkCode=as2&amp;tag=meinershagenf-20&amp;linkId=PLOEYSUEMJZ53KR2">The Passionate Programmer: Creating a Remarkable Career in Software Development (Pragmatic Life)</a> by Chad Fowler. </p>
<p>In it, he suggests that, </p>
<blockquote>
<p>Our industry tends to practice on the job.</p>
</blockquote>
<p>He then relates our craft to the art of playing music, and, </p>
<blockquote>
<p>Musicians are paid to perform in public—not to practice. </p>
</blockquote>
<p>So why would we expect to do it differently in our profession?</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683415787470/ec78ffa4-1ddf-440c-82b5-7ddc0bf0b411.jpeg" alt="A Practicing Violinist" /></p>
<p>It takes hours of practice in order to learn our craft and, unfortunately, too many are practicing on the job these days, because it is acceptable. You cannot learn everything that you ought to know as a software craftsman by merely writing code for production software. Focusing on certain aspects is needed in order to increase the quality and resilience of what we produce. </p>
<p>One of the areas that musicians focus on developing is <em><strong>physical/coordination</strong></em> or focusing on fundamental technical aspects of playing an instrument. They do this by playing scales in all of the range of the instrument, building the muscles in their lips or gaining callouses in their fingers, practicing dynamics with their diaphragms, etc. They cannot always be playing nice sounding music - they have to play simple, focused, seemingly monotonous exercises to focus on these fundamentals.</p>
<h2 id="heading-how-to-practice">How To Practice</h2>
<p>How can a software craftsman do the same? </p>
<p>They can practice the full range of functionality available to them within a certain language, platform, tool, or technique, using them in private exercises known as <em><strong><a target="_blank" href="http://codekata.com/">code katas</a></strong></em> or building a <em><strong>demo project</strong></em>.  </p>
<p>And even though they may not prove expertise in a particular technology, I have found <em><strong>certification exams</strong></em> to be invaluable in forcing me to look at the full scope of functionality that a platform provides.  </p>
<p>For even more accountability and support, you could start/join a <em><strong><a target="_blank" href="http://codingdojo.org/">coding dojo</a></strong></em>, getting involved with a community of like-minded people wanting to grow in their knowledge and skills as well.</p>
<p>So spend some time thinking about what tools you already know something about and start practicing coding in areas of that tool or technique that you are not familiar with.  Get to know what is available and practice the full range of motion.  You will be much more prepared the next time you need to use that toolset.</p>
<p>Feel free to comment below on other suggestions you have for practicing our craft.</p>
]]></content:encoded></item><item><title><![CDATA[Readability]]></title><description><![CDATA[Is creating readable code an important feature of writing quality software?
Is it something that you would mention when reviewing code for one of your team members?
Typically, when we review code we focus on making sure that:

It does what it is supp...]]></description><link>https://qualitysoftwarematters.com/readability</link><guid isPermaLink="true">https://qualitysoftwarematters.com/readability</guid><dc:creator><![CDATA[Todd Meinershagen]]></dc:creator><pubDate>Thu, 25 Jun 2015 05:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1683415782235/39a2a991-34b0-4ce8-8e1d-09980bf972c8.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Is creating readable code an important feature of writing quality software?</p>
<p>Is it something that you would mention when reviewing code for one of your team members?</p>
<p>Typically, when we review code we focus on making sure that:</p>
<ol>
<li><p>It does what it is supposed to do</p>
</li>
<li><p>It handles potential failures</p>
</li>
<li><p>It avoids duplication</p>
</li>
<li><p>It performs well if it is computationally intensive</p>
</li>
</ol>
<p>But when it comes to the readability of someone's code, we often don't want to mention it.</p>
<p>Why?</p>
<p>For some, it might be related to fear of being accused of being petty or nit-picky. Others might not want to stifle a fellow developer's personal expression or creativity. And others might be more focused on getting things done and feel that focusing on readability is a waste of valuable developer time.</p>
<h1 id="heading-is-readability-important">Is Readability Important?</h1>
<p>Today, I would like to suggest that readability is important. And, I will start by providing a couple of code samples to demonstrate my point.</p>
<p>Take a look at the following SQL statement and think about how long it takes you to figure out what it does.</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> dbo.MyTable <span class="hljs-keyword">WHERE</span> ((<span class="hljs-keyword">PATINDEX</span>(<span class="hljs-string">'%[0-9]%'</span>, @Filter) = <span class="hljs-number">0</span>) <span class="hljs-keyword">AND</span> (@Filter  <span class="hljs-keyword">LIKE</span> <span class="hljs-string">'%,%'</span>))
</code></pre>
<p>Now, take a look at the same code that has been made more readable.</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span>    *
<span class="hljs-keyword">FROM</span>    dbo.MyTable
<span class="hljs-keyword">WHERE</span>    (
        (@filterContainsNumbers = <span class="hljs-number">1</span>) 
        <span class="hljs-keyword">AND</span> 
        (@filterContainsComma = <span class="hljs-number">1</span>)
    )
</code></pre>
<p>By using the simple concepts of <strong>using reader-friendly layout</strong> and <strong>using intention revealing variable names</strong>, someone can quickly scan your code and understand it within a matter of seconds. The first example would probably take a few minutes to restructure the layout and look up the definition of the <code>PATINDEX</code> function.</p>
<p>Take a look at another code example written in C#.</p>
<pre><code class="lang-csharp"><span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">RenderRemainingMoop</span>(<span class="hljs-params">Liability source</span>)</span>
{
    <span class="hljs-keyword">var</span> remainingMoop = source.OopRemaining + source.OopApplied;
    <span class="hljs-keyword">return</span> remainingMoop == <span class="hljs-number">9999999999</span> ? String.Empty : OopRemaining.ToString(<span class="hljs-string">"{0:c}"</span>);
}
</code></pre>
<p>Now take a look at the more readable version.</p>
<pre><code class="lang-csharp"><span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">RenderRemainingMaxOutOfPocket</span>(<span class="hljs-params">Liability liability</span>)</span>
{
    <span class="hljs-keyword">const</span> LiabilityMaxNumber = <span class="hljs-number">9999999999</span>;
    <span class="hljs-keyword">var</span> remainingMaxOutOfPocket = liability.OutOfPocketRemaining + liability.OutOfPocketApplied;

    <span class="hljs-keyword">return</span> remainingMaxOutOfPocket == LiabilityMaxNumber 
        ? String.Empty
        : OutOfPocketRemaining.ToString(<span class="hljs-string">"{0:c}"</span>);
}
</code></pre>
<p>In addition to layout, using variables to <strong>provide context for magic numbers and strings</strong> and <strong>being descriptive</strong> instead of using abbreviations can better reveal what code is doing.</p>
<h1 id="heading-the-golden-rule">The Golden Rule</h1>
<p>In both of the readable code samples, the developer focused not only on getting the job done, but also on making sure that future readers of their code would easily comprehend it.</p>
<p>And why is this important?</p>
<p>Because it makes the code more <strong><em>maintainable</em></strong> and <strong><em>flexible</em></strong>.</p>
<p>As mentioned in a <a target="_blank" href="http://www.qualitysoftwarematters.com/2015/06/what-is-software-quality.html">previous post</a> on software quality, <strong><em>maintainability is the effort required to locate and fix an error in an operational program</em></strong>. If your code is more readable, developers will be able to quickly understand it, which translates into quicker fixes. In that <a target="_blank" href="http://www.qualitysoftwarematters.com/2015/06/what-is-software-quality.html">same article</a>, it was also mentioned that <strong><em>flexibility is the effort required to modify an operational program</em></strong>. When developers need to add functionality to existing code, making it more readable will also allow them to quickly get up to speed and know where to place their functionality.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683415780840/b08bd8cd-fe23-452c-a4e5-845b66da5615.jpeg" alt="the-golden-rule" /></p>
<p>In both situations, you will be making someone else's job easier. As the golden rule states,</p>
<blockquote>
<p>Do unto others what you would have them do unto you.</p>
</blockquote>
<p>You never know when that someone else might be you!</p>
<h1 id="heading-practicing-the-golden-rule">Practicing the Golden Rule</h1>
<p>So, what can we do to make our code more readable for others?</p>
<h2 id="heading-using-intention-revealing-names">Using Intention Revealing Names</h2>
<p>Everything in software has a name. And every time you name something, you have the opportunity to reveal its intention.</p>
<h3 id="heading-be-descriptive">Be Descriptive</h3>
<p>When naming things, be as descriptive as possible, and don't be afraid to use long names. Modern languages don't have many constraints when it comes to naming things, and the more descriptive, the better for the reader. There is no excuse for using abbreviations.</p>
<h3 id="heading-provide-context-for-magic-numbers-and-strings">Provide Context for Magic Numbers and Strings</h3>
<p>When using magic numbers or strings, make sure to assign them to a constant with a meaningful name. It helps to dispel the magic.</p>
<h3 id="heading-be-ubiquitous">Be Ubiquitous</h3>
<p><a target="_blank" href="http://www.amazon.com/gp/product/0321125215/ref=as_li_tl?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0321125215&amp;linkCode=as2&amp;tag=meinershagenf-20&amp;linkId=6CZABSYJYOAQGC7U"><img src="http://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;ASIN=0321125215&amp;Format=_SL250_&amp;ID=AsinImage&amp;MarketPlace=US&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=meinershagenf-20" alt /></a></p>
<p><img src="http://ir-na.amazon-adsystem.com/e/ir?t=meinershagenf-20&amp;l=as2&amp;o=1&amp;a=0321125215" alt /></p>
<p>In Eric Evan's ground-breaking book, <a target="_blank" href="http://www.amazon.com/gp/product/0321125215/ref=as_li_tl?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0321125215&amp;linkCode=as2&amp;tag=meinershagenf-20&amp;linkId=6CZABSYJYOAQGC7U">Domain-Driven Design: Tackling Complexity in the Heart of Software</a></p>
<p><img src="http://ir-na.amazon-adsystem.com/e/ir?t=meinershagenf-20&amp;l=as2&amp;o=1&amp;a=0321125215" alt /></p>
<p>, he establishes the concept of <a target="_blank" href="http://martinfowler.com/bliki/UbiquitousLanguage.html">ubiquitous language</a>, which establishes a common set of terms that can be used by both developers and business people alike. This helps to reduce the cognitive friction and potential confusion of having to translate between business concepts and code.</p>
<p>When you are naming something, prefer to use your domain's ubiquitous language rather than technical jargon. It will help reduce time and misunderstandings in the future.</p>
<h3 id="heading-avoid-data-types-in-names">Avoid Data Types in Names</h3>
<p>In the past, using Hungarian notation to prepend an abbreviated data type to a variable name (<strong>examples</strong>: iCounter, bIsValid, txtFirstName, etc.) was in vogue, but it obscures the name by mixing the semantic meaning of a variable and its underlying data type. Modern development environments can easily reveal the type of a variable by hovering over the variable during debugging.</p>
<h2 id="heading-using-reader-friendly-layout">Using Reader-Friendly Layout</h2>
<p>As shown earlier, laying out your code can make a big difference in how quickly a fellow developer (or even you, if you haven't seen the code for a while) can comprehend your code.</p>
<h3 id="heading-show-logical-structure">Show Logical Structure</h3>
<p>Layout your code to emphasize the logical structure by using indentations and new lines. The examples below demonstrate this transformation.</p>
<pre><code class="lang-sql"><span class="hljs-comment">--BEFORE</span>
IF (@filter LIKE '%to%') <span class="hljs-keyword">BEGIN</span> <span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> dbo.MyTable <span class="hljs-keyword">END</span>
<span class="hljs-keyword">ELSE</span> <span class="hljs-keyword">BEGIN</span> <span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> dbo.MyOtherTable <span class="hljs-keyword">END</span>
</code></pre>
<pre><code class="lang-sql"><span class="hljs-comment">--AFTER</span>
IF (@filter LIKE '%to%')
    <span class="hljs-keyword">BEGIN</span>
        <span class="hljs-keyword">SELECT</span>    *
        <span class="hljs-keyword">FROM</span>    dbo.MyTable
    <span class="hljs-keyword">END</span>
<span class="hljs-keyword">ELSE</span>
    <span class="hljs-keyword">BEGIN</span>
        <span class="hljs-keyword">SELECT</span>    *
        <span class="hljs-keyword">FROM</span>    dbo.MyOtherTable
    <span class="hljs-keyword">END</span>
</code></pre>
<h3 id="heading-avoid-run-on-sentences">Avoid Run-on Sentences</h3>
<p>Just as in good writing, you want to avoid the use of run-on sentences in your code. Instead of putting everything on one line as in the following example that uses a fluent syntax:</p>
<pre><code class="lang-csharp"><span class="hljs-comment">//BAD</span>
<span class="hljs-keyword">var</span> customers = eventsRepository.GetAll().Where(e =&gt; e.Date &gt; DateTime.Now).Select(e =&gt; <span class="hljs-keyword">new</span> Customer(e.FirstName, e.LastName));
</code></pre>
<p>you can do the following:</p>
<pre><code class="lang-csharp"><span class="hljs-comment">//BETTER</span>
<span class="hljs-keyword">var</span> customers = eventsRepository
    .GetAll()
    .Where(e =&gt; e.Date &gt; DateTime.Now)
    .Select(e =&gt; <span class="hljs-keyword">new</span> Customer(e.FirstName, e.LastName));
</code></pre>
<p>Or, instead of nesting multiple statements into one line for efficiency:</p>
<pre><code class="lang-csharp"><span class="hljs-comment">//BAD</span>
<span class="hljs-keyword">var</span> customer = GetOrderFor(GetCustomerFor(HttpContext.Current.User.Identity.Name), Convert.ToInt32(Session[<span class="hljs-string">"orderId"</span>]));
</code></pre>
<p>you might want to do the following:</p>
<pre><code class="lang-csharp"><span class="hljs-comment">//BETTER</span>
<span class="hljs-keyword">var</span> username = HttpContext.Current.User.Identity.Name;
<span class="hljs-keyword">var</span> customer = GetCustomerFor(username);
<span class="hljs-keyword">var</span> orderId = Convert.ToInt32(Session[<span class="hljs-string">"orderId"</span>]);
<span class="hljs-keyword">var</span> order = GetOrderFor(customer, orderId);
</code></pre>
<p>While there may not always be universally accepted practices when it comes to layout, each team should decide on rules for code formatting and stick to them. Static code analysis tools can help to enforce those rules and modern editors include utilities for automatically formatting code according to your rules as it is being written.</p>
<h2 id="heading-handling-conditionals">Handling Conditionals</h2>
<p>Another area where code can become unreadable is when using boolean logic in <code>if</code> and <code>while</code> statements.</p>
<h3 id="heading-extracting-conditional-logic">Extracting Conditional Logic</h3>
<p>For example, while the following code sample is fairly readable, it can be improved.</p>
<pre><code class="lang-csharp"><span class="hljs-keyword">if</span> (rolls[frameIndex] + rolls[frameIndex + <span class="hljs-number">1</span>] == <span class="hljs-number">10</span>) <span class="hljs-comment">// spare</span>
{
    score += <span class="hljs-number">10</span> + rolls[frameIndex + <span class="hljs-number">2</span>];
} 
<span class="hljs-keyword">else</span> 
{
    score += rolls[frameIndex] + rolls[frameIndex + <span class="hljs-number">1</span>];
}
</code></pre>
<p>Simply extract the logic contained in the boolean expression to another method, allowing the reader to understand the conditional logic from a conceptual point of view - in this case bowling a spare.</p>
<pre><code class="lang-csharp"><span class="hljs-keyword">if</span> (IsSpare(frameIndex))
{
    score += <span class="hljs-number">10</span> + spareBonus(frameIndex);
} 
<span class="hljs-keyword">else</span> 
{
    score += <span class="hljs-number">10</span> + sumOfBallsInFrame(frameIndex);
}
</code></pre>
<p>Most modern development environments have built-in refactoring utilities that make this kind of operation trivial.</p>
<h3 id="heading-negative-conditionals">Negative Conditionals</h3>
<p>Negative conditional logic can also obscure the meaning of an expression by creating cognitive dissonance that requires the reader to interpret. This wasted time could be alleviated by re-stating the condition in positive terms by creating a method to return the opposite of the intended expression.</p>
<p>For example,</p>
<pre><code class="lang-csharp"><span class="hljs-keyword">if</span> (!String.IsNullOrEmpty(<span class="hljs-keyword">value</span>))
    doSomething();
</code></pre>
<p>could very easily have been written as the following.</p>
<pre><code class="lang-csharp"><span class="hljs-keyword">if</span> (ContainsText(<span class="hljs-keyword">value</span>))
    doSomething();
</code></pre>
<p><a target="_blank" href="http://www.amazon.com/gp/product/0132350882/ref=as_li_tl?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0132350882&amp;linkCode=as2&amp;tag=meinershagenf-20&amp;linkId=V5RP3A3INHPV7BIR"><img src="http://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;ASIN=0132350882&amp;Format=_SL250_&amp;ID=AsinImage&amp;MarketPlace=US&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=meinershagenf-20" alt /></a></p>
<p><img src="http://ir-na.amazon-adsystem.com/e/ir?t=meinershagenf-20&amp;l=as2&amp;o=1&amp;a=0132350882" alt /></p>
<p>For more information on making your code readable, check out Bob Martin's book, <a target="_blank" href="http://www.amazon.com/gp/product/0132350882/ref=as_li_tl?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0132350882&amp;linkCode=as2&amp;tag=meinershagenf-20&amp;linkId=V5RP3A3INHPV7BIR">Clean Code: A Handbook of Agile Software Craftsmanship</a></p>
<p><img src="http://ir-na.amazon-adsystem.com/e/ir?t=meinershagenf-20&amp;l=as2&amp;o=1&amp;a=0132350882" alt /></p>
]]></content:encoded></item><item><title><![CDATA[Failing Fast]]></title><description><![CDATA[Raise your hand if you have seen this before in your development or production error logs.
System.NullReferenceException: Object reference not set to an instance of an object.

As you might have guessed, this is informing us that we are calling a met...]]></description><link>https://qualitysoftwarematters.com/failing-fast</link><guid isPermaLink="true">https://qualitysoftwarematters.com/failing-fast</guid><dc:creator><![CDATA[Todd Meinershagen]]></dc:creator><pubDate>Fri, 19 Jun 2015 05:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1683416421113/3de9ddac-52fd-48f8-b377-b90bad307e57.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Raise your hand if you have seen this before in your development or production error logs.</p>
<pre><code class="lang-plaintext">System.NullReferenceException: Object reference not set to an instance of an object.
</code></pre>
<p>As you might have guessed, this is informing us that we are calling a method or property on an object that is currently null. The stack trace might be able to help us to locate where the error occurred. However, an ambiguous error like this can be hard to troubleshoot for multiple reasons.</p>
<ul>
<li>If the stack trace does not have line numbers and multiple local variables exist within the method, it can be hard to determine which variable was null.</li>
</ul>
<pre><code class="lang-csharp"><span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">Method</span>(<span class="hljs-params"></span>)</span>
{
    <span class="hljs-keyword">var</span> person1 = <span class="hljs-keyword">new</span> Person{ FirstName = <span class="hljs-string">"Todd"</span>, LastName = <span class="hljs-string">"Meinershagen"</span> };
    <span class="hljs-keyword">var</span> person2 = <span class="hljs-keyword">new</span> Person();

    Console.WriteLine(person1.LastName);
    Console.WriteLine(person2.FirstName); <span class="hljs-comment">//kapow!</span>
}

<span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">Person</span>
{
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">string</span> FirstName { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; }
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">string</span> LastName { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; }
}
</code></pre>
<ul>
<li>If the variable was an input parameter, it can be hard to determine which method within the call stack the null reference was introduced.</li>
</ul>
<pre><code class="lang-csharp"><span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">Method1</span>(<span class="hljs-params"></span>)</span>
{
    Person person = <span class="hljs-literal">null</span>;
    Method2(person);
}

<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">Method2</span>(<span class="hljs-params">Person person</span>)</span>
{
    Method3(person);
}

<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">Method3</span>(<span class="hljs-params">Person person</span>)</span>
{
    Console.WriteLine(person.FirstName); <span class="hljs-comment">//kapow!</span>
}
</code></pre>
<h3 id="heading-failing-fast-enhances-maintainability">Failing Fast Enhances Maintainability</h3>
<p>In my <a target="_blank" href="http://www.qualitysoftwarematters.com/2015/06/what-is-software-quality.html">last post</a>, I talked about the various factors that define software quality. One of those, maintainability, is very important, because it reduces <strong><em>the effort required to locate and fix an error in an operational program</em></strong>. Using a technique like <strong><em>failing fast</em></strong> can enable you and your team to locate errors more quickly in both development and production.</p>
<p>So, what does it mean to fail fast?</p>
<p>It means that rather than write code that ignores or band-aids an issue (like setting default values) and allows the code to limp along throughout the execution of your program, you fail "immediately and visibly" the minute that you are aware that there is an issue.</p>
<h3 id="heading-assertions-are-the-key">Assertions are the Key</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683415776003/b992c452-f19c-4d3a-8e5e-78bc7ad38b7e.jpeg" alt="assert-sign" /></p>
<p>In order to fail fast, the key is to use assertions in your code. An assertion is code that checks for a condition, and if the condition is not met, fails. In the case of the null object reference, you can do the following:</p>
<pre><code class="lang-csharp"><span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">Method</span>(<span class="hljs-params"><span class="hljs-keyword">int</span> id</span>)</span>
{
    <span class="hljs-keyword">var</span> person = _gateway.GetPerson(id);

    <span class="hljs-keyword">if</span> (person == <span class="hljs-literal">null</span>)
    {
        <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> ArgumentNullException(<span class="hljs-string">"person"</span>);
    }

    Console.WriteLine(person1.LastName);
    Console.WriteLine(person2.FirstName);
}

<span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">Person</span>
{
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">string</span> FirstName { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; }
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">string</span> LastName { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; }
}
</code></pre>
<p>For null references, I like to check in places where two methods or classes interact:</p>
<ul>
<li><p><strong>Constructor</strong>: verify any dependencies passed in by another class</p>
</li>
<li><p><strong>Method</strong>: check any input parameters passed in by another method or class</p>
</li>
<li><p><strong>Method</strong>: check the response from another method or class, as in the case with the Gateway call above</p>
</li>
</ul>
<h3 id="heading-drying-up-your-assertions">Drying Up Your Assertions</h3>
<p>After using these kind of assertions throughout your code, you would want to DRY (don't repeat yourself) your code and create reusable assertions. Below is one example.</p>
<pre><code class="lang-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">Assert</span>
{
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">IsNotNull</span>(<span class="hljs-params"><span class="hljs-keyword">object</span> <span class="hljs-keyword">value</span>, <span class="hljs-keyword">string</span> paramName</span>)</span>
    {
        <span class="hljs-keyword">if</span> (<span class="hljs-keyword">value</span> == <span class="hljs-literal">null</span>)
        {
            <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> ArgumentNullException(paramName);
        }
    }
}
</code></pre>
<p>You might also look into third party libraries such as <a target="_blank" href="http://www.nuget.org/packages/Magnum/">Magnum by Chris Patterson</a> that are available as NuGet packages. Below is an example using the Guard class that Magnum provides for these kind of common assertions.</p>
<pre><code class="lang-csharp"><span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">Method</span>(<span class="hljs-params"><span class="hljs-keyword">int</span> id</span>)</span>
{
    <span class="hljs-keyword">var</span> person = _gateway.GetPerson(id);

    Guard.AgainstNull(person, <span class="hljs-string">"person"</span>);

    Console.WriteLine(person1.LastName);
    Console.WriteLine(person2.FirstName); <span class="hljs-comment">//kapow!</span>
}

<span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">Person</span>
{
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">string</span> FirstName { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; }
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">string</span> LastName { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; }
}
</code></pre>
<p>Another option, if you are using the .NET framework, is <a target="_blank" href="http://research.microsoft.com/en-us/projects/contracts/">Microsoft's Code Contracts</a>. These allow the developer to specify pre- and post-conditions that can also be seen in the documentation of a given method. A discussion of their use is outside the scope of this article.</p>
<h3 id="heading-is-failing-fast-robust">Is Failing Fast Robust?</h3>
<p>At this point, some may object and say this technique of failing fast will create fragile software. However, by failing fast, errors will more likely be found during development and testing of your software, rather than in production where it really counts. And if a bug does escape in production, your team will more likely be able to fix the issue quickly by failing closer to where the issue originally occurred.</p>
<p>Another objection to this style of programming is that it will more likely cause the system to crash in front of the user. One way to mitigate this is to use a global error handler that gracefully displays a user-friendly, generic error message to the user while providing the error details to developers through logs or email. In the case of non-interactive applications such as batch processes or windows services, you don't have to display a message, but after handling the error globally, operations continue by moving on to the next action/transaction.</p>
<h3 id="heading-other-resources">Other Resources</h3>
<p>If you are interested in reading more about the concept of failing fast, check out James Shore's <a target="_blank" href="http://www.martinfowler.com/ieeeSoftware/failFast.pdf">article for IEEE magazine</a> discussing the same topic.</p>
]]></content:encoded></item><item><title><![CDATA[What is Software Quality?]]></title><description><![CDATA[What would you say if I asked you what are the marks of high quality software?  
Would you have answered, "a really nice/slick/sexy user interface?"  Or perhaps you would have said, "absence of known defects or bugs."  Those in the TDD camp might hav...]]></description><link>https://qualitysoftwarematters.com/what-is-software-quality</link><guid isPermaLink="true">https://qualitysoftwarematters.com/what-is-software-quality</guid><dc:creator><![CDATA[Todd Meinershagen]]></dc:creator><pubDate>Sun, 14 Jun 2015 05:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1683415771918/0b2e0bbe-6bc9-430d-b91c-6964492e06ee.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>What would you say if I asked you what are the marks of high quality software?  </p>
<p>Would you have answered, "a really nice/slick/sexy user interface?"  Or perhaps you would have said, "absence of known defects or bugs."  Those in the TDD camp might have replied, "thoroughly tested and validated with automation."  Or an architect might have preached about the importance of one or more of the -ilities.</p>
<h3 id="heading-a-history-of-quality">A History of Quality</h3>
<p>Turns out that same question was asked of Jim McCall and his answer was captured in a <a target="_blank" href="http://oai.dtic.mil/oai/oai?verb=getRecord&amp;metadataPrefix=html&amp;identifier=ADA049014">study he conducted for the Air Force in 1977</a>.  What's surprising is that its findings are very similar to what we still claim as quality for applications today.</p>
<p>In his study on the subject, he initially identified 55 factors of quality.  In order to make the study more practical he reduced those 55 quality factors down to 11 and grouped them into 3 categories:  </p>
<ul>
<li><strong>Product operation</strong> - how well it runs</li>
<li><strong>Product revision</strong> - how well it can be changed, tested, and deployed</li>
<li><strong>Product transition</strong> - how well it can be moved to other platforms and interface with other systems</li>
</ul>
<p>The diagram below shows a visual representation of his findings.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683415770504/9e514842-6592-4a47-b1c1-28ae5d82f7b0.gif" alt="McCall's Quality Model" /></p>
<h3 id="heading-definitions-of-quality-factors">Definitions of Quality Factors</h3>
<p>Below are definitions of each of the quality factors.</p>
<ul>
<li><strong>Correctness</strong> - Extent to which a program satisfies its specifications and fulfills the user's mission objectives.</li>
<li><strong>Reliability</strong> - Extent to which a program can be expected to perform its intended function with required precision.</li>
<li><strong>Usability</strong> - Effort required to learn, operate, prepare input, and interpret output of a program.</li>
<li><strong>Integrity</strong> - Extent to which access to software or data by unauthorized persons can be controlled.</li>
<li><strong>Efficiency</strong> - The amount of computing resources and code required by a program to perform a function.</li>
<li><strong>Maintainability</strong> - Effort required to locate and fix an error in an operational program.</li>
<li><strong>Flexibility</strong> - Effort required to modify an operational program.</li>
<li><strong>Testability</strong> - Effort required to test a program to insure it performs its intended function.</li>
<li><strong>Portability</strong> - Effort required to transfer a program from one hardware configuration and/or software system environment to another.</li>
<li><strong>Reusability</strong> - Extent to which a program can be used in other applications - related to the packaging and scope of the functions that programs perform.</li>
<li><strong>Interoperability</strong> - Effort required to couple one system with another.</li>
</ul>
<h3 id="heading-todays-view-on-quality">Today's View on Quality</h3>
<p>This list should help you to think at a high level about the necessary factors involved with creating high quality software.  In more recent years, the literature on quality group the factors under either internal or external quality which are more concerned with the <strong><em>stakeholder</em></strong> rather than the <strong><em>product</em></strong>.</p>
<ul>
<li><strong>External Quality</strong> - concerned with the <strong><em>end user's</em></strong> experience in <strong><em>using</em></strong> the product; these include all of the Product Operation factors</li>
<li><strong>Internal Quality</strong> - concerned with the <strong><em>developer's</em></strong> experience in <strong><em>maintaining</em></strong> the product; these include all of the factors listed in the Product Revision and Product Transition categories.   </li>
</ul>
<p>While the external quality is of utmost importance in delighting customers, if internal quality factors are ignored, over time, delivering new external quality will be hampered.</p>
]]></content:encoded></item><item><title><![CDATA[Fired Up]]></title><description><![CDATA[In my last post, I shared with you the reasons why I wanted to start a new blog.  However, I forgot to mention that the major impetus for grabbing the qualitysoftwarematters.com domain name came from my participation in a free blogging course provide...]]></description><link>https://qualitysoftwarematters.com/fired-up</link><guid isPermaLink="true">https://qualitysoftwarematters.com/fired-up</guid><dc:creator><![CDATA[Todd Meinershagen]]></dc:creator><pubDate>Thu, 04 Jun 2015 05:00:00 GMT</pubDate><content:encoded><![CDATA[<p>In my <a target="_blank" href="http://www.qualitysoftwarematters.com/2015/05/welcome.html">last post</a>, I shared with you the reasons why I wanted to start a new blog.  However, I forgot to mention that the major impetus for grabbing the <a target="_blank" href="http://www.qualitysoftwarematters.com">qualitysoftwarematters.com</a> domain name came from my participation in a <a target="_blank" href="http://devcareerboost.com/blog-course/">free blogging course</a> provided by <a target="_blank" href="http://simpleprogrammer.com">John Sonmez of simpleprogrammer.com</a>. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683415766481/16169116-d67f-4f63-9f96-bf95d22f9c85.jpeg" alt="simpleprogrammer-logo" /></p>
<p>If you haven't heard of him, you should definitely check out <a target="_blank" href="http://simpleprogrammer.com">his blog</a>.  I have found a wealth of advice on a lot of topics that should interest all developers.  And even though I've had <a target="_blank" href="http://toddmeinershagen.blogspot.com">a blog</a> previously for many years, John really helped me by giving guidance on focusing my efforts.</p>
<p>In six email lessons, I have learned:</p>
<ul>
<li>Why having a blog can help me in my career</li>
<li>The importance of specialization and theme selection</li>
<li>How to:<ul>
<li>Host my own blog</li>
<li>Generate ideas for blog posts</li>
<li>Be consistent</li>
<li>Market my blog</li>
</ul>
</li>
</ul>
<p>If you haven't started your own blog or your efforts have waned with an existing one, I highly recommend that you sign up for <a target="_blank" href="http://devcareerboost.com/blog-course/">this free course</a>.  It has really fired me up!</p>
]]></content:encoded></item><item><title><![CDATA[Welcome]]></title><description><![CDATA[Welcome to my new blog on quality software matters.  This is a new home where I plan to focus on the matter of how to build quality software.  Hopefully, each week I will be able to deliver a post on some idea or question I have about the topic.
You ...]]></description><link>https://qualitysoftwarematters.com/welcome</link><guid isPermaLink="true">https://qualitysoftwarematters.com/welcome</guid><dc:creator><![CDATA[Todd Meinershagen]]></dc:creator><pubDate>Fri, 29 May 2015 05:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1683411871438/ad0da535-acef-49a2-933f-e7640bc44825.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Welcome to my new blog on quality software matters.  This is a new home where I plan to focus on the matter of how to build quality software.  Hopefully, each week I will be able to deliver a post on some idea or question I have about the topic.</p>
<p>You may be asking yourself,</p>
<blockquote>
<p>Why is Todd starting a new blog?  </p>
</blockquote>
<p>The short answer is that it helps me to clarify my own thinking.  Below is a quote I read in a book by Dr. Howard Hendricks that I think describes the process pretty well.</p>
<blockquote>
<p>“Thoughts untangle themselves over the lips and through the fingertips.”</p>
</blockquote>
<p>Isn't it funny how the simple act of talking about an idea or writing it down helps to untangle and clarify it?  </p>
<p>My other aim is to share my opinions and ideas with you.  I hope that this will be a small contribution to the community from which I have learned so much.  As Bernard of Clairvaux once said,</p>
<blockquote>
<p>There are those who seek knowledge for the sake of knowledge; that is Curiosity.  There are those who seek knowledge to be known by others; that is Vanity.  There are those who seek knowledge in order to serve; that is Love. </p>
</blockquote>
]]></content:encoded></item></channel></rss>