<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Technical Musings</title>
    <link rel="alternate" type="text/html" href="http://www.safnet.com/writing/tech/" />
    <link rel="self" type="application/atom+xml" href="http://www.safnet.com/writing/tech/atom.xml" />
    <id>tag:www.safnet.com,2011-11-05:/writing/tech//3</id>
    <updated>2012-02-16T03:06:13Z</updated>
    
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type 5.12</generator>

<entry>
    <title>A Recipe for Setting Up Automated Test Projects</title>
    <link rel="alternate" type="text/html" href="http://www.safnet.com/writing/tech/2012/02/a-recipe-for-setting-up-automated-test-projects.html" />
    <id>tag:www.safnet.com,2012:/writing/tech//3.456</id>

    <published>2012-02-16T03:04:28Z</published>
    <updated>2012-02-16T03:06:13Z</updated>

    <summary>Assuming that you are already sold on the notion of automated testing, it can be useful to put a little thought into how projects will be setup. There are many approaches to this; my approach is based on experience, the...</summary>
    <author>
        <name>Stephen Fuqua</name>
        
    </author>
    
    <category term="moles" label="Moles" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="testing" label="testing" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="unittest" label="unit test" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.safnet.com/writing/tech/">
        <![CDATA[<p>Assuming that you are already sold on the notion of automated testing, it can be 
useful to put a little thought into how projects will be setup. There are many 
approaches to this; my approach is based on experience, the wisdom in <em>xUnit 
Test Patterns</em>, and standard coding best practices. I will try to keep this 
language agnostic, though my examples will be in C#. </p>
]]>
        <![CDATA[<h3>Separate Projects</h3>
<p>First, to maximize the benefit of unit testing, let&#39;s make a clear (and 
industry standard) delineation between <em>unit</em> and <em>integration</em> 
testing:</p>
<ul>
	<li><strong>Unit test</strong> are in isolation from external resources, 
	e.g. files, databases, web services; in SQL, it might be isolation from 
	foreign keys.</li>
	<li><strong>Integration tests</strong> utilize these resources.</li>
</ul>
<p>One benefit of this distinction is that external resources may cause errors 
that have nothing to do with your code, which therefore would be false alarms. 
Another benefit is speed - the isolated unit tests will run much faster than the 
integration tests, giving you feedback that much more quickly. Slow tests will 
just frustrate you as you sit around waiting for them to complete, and you&#39;ll be 
less likely to run them frequently.</p>
<p>Thus it is best to put these into separate test projects. Run all of the unit tests 
very frequently, and run the integration test as often as is reasonable. The 
same principle applies to any automated UI or performance tests.</p>
<h3>Project Setup</h3>
<p>Each class should have its own test file, and each namespace its own folder - 
just as you would do for non-test code. If a class has many methods, or some 
methods require many different tests, it may be helpful to create multiple test 
files for a class. For example, you might have &quot;MyClassTest_MethodA.cs&quot; and 
&quot;MyClassTest_MethodB.cs&quot;.</p>
<h3>Helper Classes</h3>
<p>It is often useful to put some code into a static class for re-use across 
multiple tests. For example, if you use Guids frequently, then create a static 
Guid variable that can be re-used everywhere:</p>
<pre class="brush: csharp">
public class Helper
{
    public static Guid GuidOne = new Guid("dd28ce17-218f-42cc-a023-caaf455cdfc5");
}
</pre>
<p>I&#39;ve also used my Helper classes to build an object with other constant 
values, where that same object will be used in many different tests.</p>
<pre class="brush: csharp">
public const string TestPattern = "^[^ ]+";
public const string TestValue = "as df";

public static RegExTest BuildStandardTest()
{
    return new RegExTest()
    {
        Pattern = TestPattern,
        TestString = TestValue
    };
}
</pre>
<h3>Test Template</h3>
<p>The basic art of testing is to know your inputs and your expected outputs. At 
the code level this applies to methods / procedures; at the system level it 
applies to the application; and to the user, it typically applies to particular 
UI screens. Between these two sit the system under test. For a proper unit test, 
the system must be isolated before it is called. Finally, you must validate the 
output.</p>
<ol>
	<li>Prepare input</li>
	<li>Isolate the system under test</li>
	<li>Call the system</li>
	<li>Evaluate output</li>
</ol>
<p>Just as with regular code, test code should be well structured. As 
non-production code, it might be more forgivable to take a few shortcuts; still, comments should not 
be omitted. I like to put these four steps into the comments. The name of the 
test should clearly indicate its purpose. If there are 
multiple code paths to test for a single method, it might be challenging to come 
up with meaningful names for each. Method level comments should clearly 
describe, in plain English, the purpose of the test. To be a real stickler about 
traceability, the method-level comments might mention a user story to which the 
test applies.</p>
<p class="auto-style1">Example from my
<a href="http://reggie.codeplex.com">Reggie</a> project (more about Moles in a 
separate article):</p>

<pre class="brush: csharp">
/// &lt;summary&gt;
/// A test for the TryIt method.
/// &lt;/summary&gt;
[TestMethod()]
[HostType("Moles")]
public void t_TryIt()
{
    // Prepare input and expected values
    string pattern = "pattern";
    string testString = "testString";
    string expected = "anything will do";

    // Mockup the RegExTest class
    bool tryPatternWasRun = false;
    Reggie.BLL.Entities.Moles.MRegExTest.AllInstances.TryPatternMatch = (RegExTest iTester) =>
        {
            tryPatternWasRun = true;
            Assert.AreEqual(testString, iTester.TestString, "wrong TestString");
            Assert.AreEqual(pattern, iTester.Pattern, "wrong Pattern");
            return expected;
        };

    // Run the system under test
    string actual = ExpressionTest.TryIt(pattern, testString);

    // Validate results
    Assert.AreEqual(expected, actual, "Wrong output");
    Assert.IsTrue(tryPatternWasRun, "TryPattern wasn't run");
}
</pre>
<p>In some cases isolation may not be required; in this particular case, I knew 
that TryIt would be calling method TryPattern, and I bypassed it. Since 
TryPattern doesn&#39;t call any external resources, I didn&#39;t have to code it this 
way. But by doing so, I completely isolated the TryIt method from everything 
else.</p>
<p>The validation portion could be skipped in some cases; for example, if you 
expect an exception to be thrown, many languages will let you specify an 
&quot;expected exception&quot; rather than having to catch the exception and test its 
type. For example:</p>
<pre class="brush: csharp">
/// &lt;summary&gt;
/// A test for TryIt with null Pattern input.
/// &lt;/summary&gt;
[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
public void t_TryIt_NullPattern()
{
    // Prepare input and expected values
    string pattern = null;
    string testString = "testString";

    // Run the system under test
    ExpressionTest.TryIt(pattern, testString);
}
</pre>
]]>
    </content>
</entry>

<entry>
    <title>Mythical Man-Month: Code Reuse and Discoverability</title>
    <link rel="alternate" type="text/html" href="http://www.safnet.com/writing/tech/2012/01/mythical-man-month-code-reuse-and-discoverability.html" />
    <id>tag:www.safnet.com,2012:/writing/tech//3.454</id>

    <published>2012-01-08T02:09:21Z</published>
    <updated>2012-01-08T02:18:42Z</updated>

    <summary><![CDATA[Fifth and final installment in a series. &quot;The best way to attack the essence of building software,&quot; Dr. Brooks writes, &quot;is not to build it at all.&quot; (p222). With this he introduces a brief discussion of the importance of code...]]></summary>
    <author>
        <name>Stephen Fuqua</name>
        
    </author>
    
    <category term="documentation" label="Documentation" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="mythicalmanmonth" label="Mythical Man-Month" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="reusability" label="reusability" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.safnet.com/writing/tech/">
        <![CDATA[<p>Fifth and final
<a href="http://www.safnet.com/fcgi-bin/mt/mt-search.cgi?IncludeBlogs=3&amp;tag=Mythical%20Man-Month&amp;limit=20">
installment in a series</a>. &quot;The best way to attack the essence of building 
software,&quot; Dr. Brooks writes, &quot;is not to build it at all.&quot; (p222). With this he 
introduces a brief discussion of the importance of code reuse, and of its 
challenges.</p>
]]>
        <![CDATA[<p>Building software for reuse is expensive: it requires greater attention to 
architecture and more hardening. Perhaps more importantly, it is difficult to 
user and learn. Code intended for general use often must be more flexible, with 
a greater number of parameters, which makes it harder to understand. The biggest 
problem of all I call discoverability; that is, how does anyone know what 
code is available for reuse?</p>
<p>There are many tools and methods available to help software developers today. 
Brooks himself refers to the power of object orientation, inheritance and 
polymorphism for enabling reuse. <a href="http://martinfowler.com/refactoring/">Refactoring</a>, combined with a complete set of 
automated <a href="http://xunitpatterns.com/">unit tests</a>, should significantly reduce the up-front cost of 
developing for reusability. Language features such as
<a href="http://en.wikipedia.org/wiki/Generic_programming">Generics</a> and 
<a href="http://en.wikipedia.org/wiki/Anonymous_delegate">Anonymous 
Delegate</a> allow for a great deal of flexibility in reusable code. </p>
<p><a href="http://en.wikipedia.org/wiki/Static_program_analysis">Static code 
analysis</a> tools can help spot common flaws in security, design, naming, and more
&ndash; thereby helping to improve not only the maintainability but also the 
discovery of functionality. For the .Net developer,
<a href="http://www.safnet.com/writing/tech/2010/02/exploring-net-c.html">Pex&#39;s</a> automatic discovery of unhandled exceptions
can do much to improve, quickly, the code hardening efforts.</p>
<p><a href="http://msdn.microsoft.com/en-us/magazine/cc302121.aspx">XML code 
comments</a>, which can be enforced in static analysis, are quite helpful in 
explaining the purpose of a class and its methods. Brooks mentions the 
importance of code samples, beyond general documentation, for explaining complex 
reusable code. These can be embedded in the Remarks section of an XML comment. 
For the .Net developer, these comments can be compiled into web pages using
<a href="http://blogs.msdn.com/sandcastle">
Sandcastle</a>. Load these pages into IIS. Perhaps configure a search engine. 
Take a suggestion from Brooks by publishing a weekly summary of the new/updated 
documentation.</p>
<p>FFor all that, the human touch is probably the most potent approach;
<a href="http://stackoverflow.com/questions/23935/peer-reviews-or-pair-programming-or-both">
peer review and pair programming</a> provide ample opportunity for sharing about 
available components and modules.</p>
<p>With all these advantages today, the only excuse for not building your code 
to be reusable is that you know it won&#39;t be reused. In that case, don&#39;t waste 
your time. Refactor later if you were wrong.</p>
]]>
    </content>
</entry>

<entry>
    <title>Notes on Configuring CruiseControl.Net</title>
    <link rel="alternate" type="text/html" href="http://www.safnet.com/writing/tech/2011/12/notes-on-configuring-cruisecontrolnet.html" />
    <id>tag:www.safnet.com,2011:/writing/tech//3.452</id>

    <published>2011-12-18T04:50:23Z</published>
    <updated>2011-12-18T04:53:12Z</updated>

    <summary> Recently I began carving out some time for using CruiseControl.Net in earnest. The book Continuous Integration in .Net was, and I&#39;m sure will continue to be, of great help. Nevertheless, I think it will behoove my own memory, and...</summary>
    <author>
        <name>Stephen Fuqua</name>
        
    </author>
    
    <category term="agile" label="agile" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="tools" label="Tools" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.safnet.com/writing/tech/">
        <![CDATA[<p>
Recently I began carving out some time for using CruiseControl.Net in earnest. The book <a href="http://www.manning.com/kawalerowicz/">Continuous Integration in .Net</a> was, and I&#39;m sure will continue to be, of great help. Nevertheless, I think it will behoove my own memory, and perhaps help a few others, to record some notes on a few practical details.
</p>
]]>
        <![CDATA[<h3>AccuRev Integration</h3>
<p>Integration with the source control tool AccuRev is very easy, as I&#39;m sure is the case with other SCMs. The only problem is redundancy &ndash; and a plain text password. Each configured project needs to have a <code>&lt;sourcecontrol type=&quot;accurev&quot;&gt;</code> block within it, containing the path to the executable, login information, and workspace, and other settings.</p>
<p>
Even if there are multiple projects in the same Stream, each project must repeat that information. And due to that plain text password, it is best to use Windows security to restrict editing of the configuration file to only those who absolutely must have it. Presumably all developers in a group will have an AccuRev account; however, one of the advantages of separate accounts is the ability to track who uploaded what. How will you know if someone maliciously slips some code in using the "shared" account?
</p>
<h3>Publishers</h3>
<p>
The <code>&lt;xmllogger /&gt;</code> element is crucial for viewing detailed build results. Never go without it.
</p>
<p>The <code>&lt;email&gt;</code> element will allow distribution of alerts to groups of e-mail recipients. This is a powerful feature. How do you decide who to include? Now that I have over a dozen projects configured, I will let it run for at least a week before introducing anyone else into the distributions. That way I can make sure I don&#39;t accidentally spam them. No need to receive notifications for every-day good builds. Just send out Failed and Fixed notifications. Be sure to get the nested <code>&lt;groups&gt; &lt;group&gt;</code> right &ndash; I accidentally left out the top level at first and scratched my head for a minute when the file wouldn&#39;t validate, though the mistake wasn&#39;t that hard to find.
</p>
<p>Again, you have to enter the same configuration over and over again for each project. Unless there&#39;s something I haven&#39;t learned yet, such as the introduction of a variable.</p>
<h3>webURL</h3>
<p>Initially I tried to configure MyProject with URL <code>http://myserver/ccnet/MyProject</code>. That didn&#39;t work so well. What does work is <code>http://MyServer/ccnet/server/local/project/MyProject/ViewProjectReport.aspx</code>.
</p>
<h3>Custom Project Files</h3>
<p>Undoubtedly there is a better way to do this. But, in the tradition of red, green, refactor &ndash; in several cases I made custom csproj files that hard-coded reference links to other custom assemblies. Some of the projects were building just fine and some weren&#39;t. This definitely solved it. Now I&#39;m at green. Later perhaps I&#39;ll try to figure out exactly why the original project file failed and try to refactor. For now, this is good enough.</p>
<p>Actually, here&#39;s one more advantage of a custom project file: you can add extra steps that you don&#39;t want to run every time you build locally. For example, generating XML documentation and then running SandCastle.</p>
<h3>Unit Tests</h3>
<p>So far I have ignored unit tests in my configuration, because my unit tests tend to include a lot of database-related code. There is extensive use of mocking (via Moles) so that non-database code does not call the database, but the database code of course still does. It runs on a UnitTest database on each developer&#39;s local machine. Unless I build an automatic deployment/install system for database code changes, it would be impractical to create a UnitTest database that can be accessed by the build server. </p>
<p>
Therefore I plan to separate those tests into a different test project. The original project will now be more purely "unit tests" (as opposed to integration tests) and can be run with the project build. I could probably do more to separate the tests: for instance, try to inject a fake stored procedure response in order to test mapping code. But is that ultimately worth the extra effort? Not sure yet. It is already a bit of a shock for customers to get higher-than-expected estimates due to the extra time unit testing (though most do understand that this typically will result in higher-quality code from day 1).</p>
<h3>Next Steps</h3>
<p>I need to integrate FxCop and StyleCop for code analysis. We have written standards for code quality. Might as well automate the process of checking on adherence. SandCastle integration would also be nice &ndash; particularly if I can set it up to automatically deploy the generated documentation to a web directory on the build server.
</p>
]]>
    </content>
</entry>

<entry>
    <title>Reggie - Regular Expression Generation/Testing Tool</title>
    <link rel="alternate" type="text/html" href="http://www.safnet.com/writing/tech/2011/12/reggie---regular-expression-generationtesting-tool.html" />
    <id>tag:www.safnet.com,2011:/writing/tech//3.451</id>

    <published>2011-12-15T22:27:40Z</published>
    <updated>2011-12-15T22:29:54Z</updated>

    <summary>I&apos;ve started a new project on CodePlex, called Reggie, and posted the initial working source code. Reggie&apos;s goal is to be a simple developer tool for writing and testing Regular Expressions. It is inspired by the venerable Regulator tool and...</summary>
    <author>
        <name>Stephen Fuqua</name>
        
    </author>
    
    <category term="reggie" label="Reggie" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.safnet.com/writing/tech/">
        <![CDATA[I've started a new project on CodePlex, called <a href="http://reggie.codeplex.com/">Reggie</a>, and posted the initial working source code. Reggie's goal is to be a simple developer tool for writing and testing 
Regular Expressions. It is inspired by the venerable Regulator tool and 
will be created in WPF using the MVVM pattern.<br /> ]]>
        
    </content>
</entry>

<entry>
    <title>Mythical Man-Month: Planning for Change</title>
    <link rel="alternate" type="text/html" href="http://www.safnet.com/writing/tech/2011/12/mythical-man-month-planning-for-change.html" />
    <id>tag:www.safnet.com,2011:/writing/tech//3.450</id>

    <published>2011-12-11T17:17:59Z</published>
    <updated>2011-12-11T17:19:29Z</updated>

    <summary><![CDATA[Part four in a series. In the chapter titled &quot;Plan the System for Change,&quot; Dr. Brooks again lays out the foundations for Agile software development. His was an era of dumb-terminals and highly scheduled availability. And yet, here he is...]]></summary>
    <author>
        <name>Stephen Fuqua</name>
        
    </author>
    
    <category term="agile" label="agile" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="mythicalmanmonth" label="Mythical Man-Month" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="review" label="review" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.safnet.com/writing/tech/">
        <![CDATA[<p>Part <a href="http://www.safnet.com/fcgi-bin/mt/mt-search.cgi?IncludeBlogs=3&tag=Mythical%20Man-Month&limit=20">four in a series</a>. In the chapter titled &quot;Plan the System for Change,&quot; Dr. Brooks again lays out the foundations for Agile software development. His was an era of dumb-terminals and highly scheduled availability. And yet, here he is saying, &quot;plan to throw one away; you will, anyhow.&quot; When RAM wasn&#39;t cheap, and good programmers even more rare than today, how does a project manager or architect justify throwing out the first design <i>on purpose</i>? By recognizing that &quot;[t]he only question is whether to plan in advance to build a throwaway, or to promise to deliver the throwaway to customers.&quot;</p>]]>
        <![CDATA[
<p>This followed an analogy to the creation of a physical pilot plant for testing out a proposed manufacturing design. That sounds to me like a prototype. Spend an early iteration on a quick-and-dirty prototype of your design, run it by the users, and incorporate the feedback into a fresh implementation. But it does seem to miss the beauty of refactoring: get it working, then clean it up. Perhaps the refactoring concept did not work as well in those green-screen, procedural days, before you could re-compile every few minutes.</p>

<p>It is not sufficient, Brooks posits, to expect changing requirements and hope for the best. Thus he goes on to advocate that the software development group be organized for success in a changing environment. But he also makes the assertion that software needs more control, not less, which on the surface seems to be a call for a strict waterfall. He doesn&#39;t want tentative plans.</p>

<p>One of the signs of true genius is recognizing new data, accepting that a former conclusion might be wrong, and moving forward with the new premise. In new chapter &quot;The Mythical Man-Month after 20 Years,&quot; Brooks accepts that &quot;[t]he biggest mistake in the &quot;Build one to throw away&quot; concept is that it implicitly assumes the classical sequential or waterfall model of software construction.&quot; Thus in 1995 his vision of software development was updated to include the reality of incremental and iterative design. His 1986 paper, &quot;No Silver Bullet&quot; (ch 16) actually spelled out the need to &quot;[utilize] rapid prototyping&quot; and &quot;[grow] software organically.&quot; A common misconception about Agile development is that it is uncontrolled. In the context of the whole, Brooks is calling for careful governance without the stultifying commitment to tollgates and a single-pass design that are called for by waterfall.</p>]]>
    </content>
</entry>

<entry>
    <title>The Mythical Man-Month: Wiki and Customer Service</title>
    <link rel="alternate" type="text/html" href="http://www.safnet.com/writing/tech/2011/11/the-mythical-man-month-wiki-and-customer-service.html" />
    <id>tag:www.safnet.com,2011:/writing/tech//3.447</id>

    <published>2011-11-26T15:57:19Z</published>
    <updated>2011-11-26T16:02:18Z</updated>

    <summary>Part three in a series. Many of the recommendations Dr. Brooks makes in this work can seem outdated at first glance; however, it does not take much to bring them into today&apos;s software development environments. Take the telephone log for...</summary>
    <author>
        <name>Stephen Fuqua</name>
        
    </author>
    
    <category term="mythicalmanmonth" label="Mythical Man-Month" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="principles" label="principles" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="review" label="review" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.safnet.com/writing/tech/">
        <![CDATA[<p>Part <a href="http://www.safnet.com/fcgi-bin/mt/mt-search.cgi?IncludeBlogs=3&tag=Mythical%20Man-Month&limit=20">three in a series</a>. Many of the recommendations
Dr. Brooks makes in this work can seem outdated at first glance; however, it
does not take much to bring them into today's software development
environments. Take the <i>telephone log</i> for example:</p>

<blockquote>&quot;One useful mechanism is a <i>telephone
log</i> kept by the architect. In it he records every question and every
answer. Each week the logs of the several architects are concatenated,
reproduced, and distributed to the users and implementers. While this mechanism
is quite informal, it is both quick and comprehensive.&quot; (p69)</blockquote>
]]>
        <![CDATA[<p>Read the book for more context. Updated in modern
terms: as an architect, or any kind of <i>subject matter expert</i>
(SME), questions and answers over the phone, e-mail, or in-person should spawn
an update to the enterprise Wiki (addition or clarification). Consider pro-actively sending a list of updated Wiki pages at least once a week, or even in a brief daily status update. If the answer to an active question is
already there, find a polite way to direct the questioner to the Wiki. Here&#39;s
where good customer service is important. In many cases this might be a missed
opportunity to be of service:</p>

<blockquote>One-line e-mail: &quot;Did you look in the Wiki?&quot;</blockquote>

<p>One can imagine a much snarkier-sounding e-mail coming from
a frustrated developer who does not want to be interrupted with &quot;trivialities.&quot; But
that's an unfortunate attitude, one that fails to recognize the importance of
respect and service to other group/team members, without whom the developer&#39;s
job might be meaningless. Perhaps a better response would be:</p>

<blockquote>&quot;Yes, I had a difficult time understanding that as well. We&#39;ve
documented that in the Wiki; please click under XXXXXX and then find the link
with YYYYY in it.&quot;</blockquote>

<p>Better yet, if time permits: copy and paste from the Wiki
into an e-mail, and include the Wiki link for future reference. This is, of
course, a double-edged sword. Somehow, someway, &quot;users and implementers&quot; must
be encouraged to read the documentation for themselves, and discouraged from
asking a thousand questions that have already been answered.</p>
<p>I do
not recall that Brooks&#39;s sagacity encompassed this area. The best that I've
come up with is this: offer to schedule an hour with the individual later in
the day/week, and ask the individual to hold all but the most critical questions until
that time. This gives the person an opportunity to find their own answers,
allows you to continue focusing on your current efforts, and the face-to-face
time may even be more appreciated than the individual responses would have been.</p>]]>
    </content>
</entry>

<entry>
    <title>The Mythical Man-Month: Conceptual Integrity</title>
    <link rel="alternate" type="text/html" href="http://www.safnet.com/writing/tech/2011/11/mythical-man-month-conceptual-integrity.html" />
    <id>tag:www.safnet.com,2011:/writing/tech//3.446</id>

    <published>2011-11-20T16:30:21Z</published>
    <updated>2011-11-26T16:00:56Z</updated>

    <summary>Aside from being a fascinating inside-look at some of the challenges faced by the mainframe programmers of the sixties, The Mythical Man-Month presents many lessons-learned that are no less applicable today. This is the second article in a series exploring...</summary>
    <author>
        <name>Stephen Fuqua</name>
        
    </author>
    
    <category term="analysis" label="analysis" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="mythicalmanmonth" label="Mythical Man-Month" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="quality" label="quality" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="review" label="Review" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.safnet.com/writing/tech/">
        <![CDATA[<p>Aside from being a fascinating inside-look at some of the challenges faced by the mainframe programmers of the sixties, <i>The Mythical Man-Month</i> presents many lessons-learned that are no less applicable today. This is the <a href="http://www.safnet.com/fcgi-bin/mt/mt-search.cgi?IncludeBlogs=3&tag=Mythical%20Man-Month&limit=20">second article in a series</a> exploring some of these lessons, in particular:  conceptual integrity.
</p>
]]>
        <![CDATA[<p>
&quot;Conceptual integrity&quot; is one of the most important concepts in the book. Many of Dr. Brooks&#39;s recommendations throughout the book are predicated on the importance of ensuring a system&#39;s coherence, from the project management to user interface, from documentation to memory management optimizations. Brooks</p>
<blockquote>
&nbsp;&quot;contend[s] that conceptual integrity is <i>the</i> most important consideration in system design. It is better to have a system omit certain anomalous features and improvements, but to reflect one set of design ideas, than to have one that contains many good but independent and uncoordinated ideas.&quot; (p42)
</blockquote><p>
Brooks talks about simplicity being more valuable than diversity of function &ndash;  because it is easier to construct and utilize a coherent, slightly simpler system than to create and use a complex one. How often have any of us opted for the simpler device rather than the gadget with all the bells and whistles, simply because we were concerned that the extras would break, or would be hard to learn? The same goes with software systems: keep the design simple. Only add as much diversity and complexity as are needed to get the job done. I suspect that this approach was influential in the formation of <a href="http://agilemanifesto.org/principles.html">Agile principle</a> number 10: &quot;<i>Simplicity &ndash; the art of maximizing the amount of work not done &ndash; is essential.</i>&quot;
</p><p>
I think the author would agree that this principle is to be applied to the system generally, and must be applied very carefully when looking at individual components. As I read this section, I reflected back on mistakes made a few years before, when I first came onto a project in a file-processing environment. I couldn&#39;t articulate a significant problem until reading this: none of the .Net developers involved understood the system architecture, and therefore our solutions were incoherent. We had diverse ways of reporting errors (if any), of accepting input parameters, of creating output data.
</p><p>
Even as some of the individual lessons were learned, the bigger picture was not realized. Only after reading this book did I realize why some people have been less-than-thrilled about our use of Reporting Services for some new reports, 
instead of plain text, and I just installed a new application that does the same. We did so in order to have an easier time designing the report, and to have better looking output (simpler for the programmers). That&#39;s nice, but not at all what our users are used to, expected, or wanted. 
</p><p>
What they want is something that prints the same way as all of the existing file-based reports. They want to be able to find the file on the system and reprint it when the existing paper copy gets chewed up. They don&#39;t want to learn how to go to Reporting Services to print the report; plus, we made the mistake of using the .Net version (RDLC). If reprints are needed, we&#39;ll have to either output a permanent PDF, or support two versions &ndash;  the other loaded into SQL Server&#39;s Report Manager. Further, I&#39;ve realized that testing is simplified when the report is in text: then it is easy to regression test the application, using a file diff tool to compare the output before and after an update.
</p><p>
We were the new kids on the architecture block, and we didn&#39;t get it. Sometimes we still don&#39;t. Brooks makes an analogy about ancient cathedrals. That RDLC report &ndash; it&#39;s like repairing a section of a Gothic cathedral by building a cantilevered steel-and glass structure. It might technically fit the need, but it probably won&#39;t be what anybody wanted.
</p>
]]>
    </content>
</entry>

<entry>
    <title>Rediscovering C++  / Performing SQL Bulk Copy Operations</title>
    <link rel="alternate" type="text/html" href="http://www.safnet.com/writing/tech/2011/11/rediscovering-c-performing-sql-bulk-copy-operations.html" />
    <id>tag:www.safnet.com,2011:/writing/tech//3.444</id>

    <published>2011-11-13T19:53:58Z</published>
    <updated>2011-11-13T19:58:46Z</updated>

    <summary>When last I worked with C++, it was while working on my master&#39;s thesis ten years ago, using a basic text editor in a Red Hat Linux 5.0 installation. A new task in front of me: replace a Reporting Services...</summary>
    <author>
        <name>Stephen Fuqua</name>
        
    </author>
    
    <category term="c" label="C++" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="coding" label="coding" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="exceptions" label="exceptions" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="performance" label="performance" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="reportingservices" label="Reporting Services" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="sqlbulkcopy" label="SqlBulkCopy" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="visualstudio" label="Visual Studio" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.safnet.com/writing/tech/">
        <![CDATA[<p>When last I worked with C++, it was while working on my master&#39;s thesis ten 
years ago, using a basic text editor in a Red Hat Linux 5.0 installation. A new 
task in front of me: replace a Reporting Services report, which was exporting to 
CSV, with a new solution that will allow me to create multiple files, with max 
150,000 records each. The first challenge is speed: with that many records, only 
bulk copy will be reasonable. The second is splitting the file. I thought about calling BCP from a C# process, 
because unfortunately managed code only offers bulk loading <em>into</em> a SQL Server 
database, not <em>from database to file</em>. But C++ is another story, thanks 
to the <a href="http://msdn.microsoft.com/en-us/library/ms130922.aspx">Bulk Copy 
Driver Extensions</a> made available by Microsoft. So, time for a C# developer 
to brush up on C++, and learn it the Visual Studio way!</p>
]]>
        <![CDATA[<p>To get started, I found the <a href="http://sqlserversamples.codeplex.com/">
Microsoft SQL Server Community Projects &amp; Samples</a> site, and the Bulk Copy 
functions documentation linked above. Download the project samples to get a 
quick-start on coding for bulk copy operations; I found the projects
<a href="http://www.bahaullah.org/bahji/worthy-trusthttp://msftdpprodsamples.codeplex.com/wikipage?title=SS2005!README%20How%20to%20bulk%20copy%20a%20SELECT%20result%20set%20%28ODBC%29&amp;referringTitle=Home">
How to bulk copy a SELECT result set</a>,
<a href="http://msftdpprodsamples.codeplex.com/wikipage?title=SS2005!README%20BulkCopyFormatAndData&amp;referringTitle=Home">
BulkCopyFormatAndData</a>, and&nbsp;
<a href="http://msftdpprodsamples.codeplex.com/wikipage?title=SS2005!README%20How%20to%20process%20ODBC%20errors%20%28ODBC%29&amp;referringTitle=Home">
How to process ODBC errors</a> particularly useful for my goal. Creating a new 
Visual C++ console application, I was able to quickly stitch together a working 
prototype that would perform a hard-coded query, using a hard-coded ODBC 
connection name, and bulk-loading to a hard-coded file. It displayed any error 
messages at the console. In customizing the error logging, I re-taught myself 
about sprintf (actually, 
<a href="http://msdn.microsoft.com/en-us/library/ce3zzk1k%2528v=vs.80%2529.aspx">sprintf_s</a>) and 
<a href="http://www.cplusplus.com/reference/iostream/stringstream/">stringstream</a>. The ODBC driver does not 
always provide a helpful message, so I threw together a few methods for testing 
whether or not I could create a file (for writing the BCP output and BCP error 
files) or whether or not a file exists already (for the BCP format file), using 
the
<a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858%2528v=vs.85%2529.aspx">
CreateFile</a> function for both.</p>
<p>Next I decided to re-learn how try/catch works in the C++ world, and chose to 
do so without the Microsoft __finally extension (<a href="http://www.cplusplus.com/doc/tutorial/exceptions/">resource 
1</a>,
<a href="http://msdn.microsoft.com/en-us/library/6dekhbbc%2528v=VS.90%2529.aspx">
resource 2</a>). I was most surprised when I found that a compilation failure 
was due to my use of the <em>new</em> keyword, as in <code>throw new MyException()</code>. 
It also took me a few tries to get the syntax correct for overriding the what() 
method for my custom exception, which is inheriting from the STL&#39;s exception 
class. It came down to getting the correct modifiers on the declaration in the 
header file, combined with a problem I ran into several times: using the 
expected namespace in the code file. That is, I couldn&#39;t simply put <code>virtual 
const char* what()</code> into my code file &ndash; I needed to put <code>virtual const char* 
<span style="background-color:yellow;">MyException::</span>what()</code>. Perhaps I needed
 a <code>using namespace</code> statement to avoid this. </p>
<p>Garbage collection is basically taken for granted in C#, but I know it is all 
up to me in C++. With the help of a Stack Overflow Q&amp;A on
<a href="http://stackoverflow.com/questions/76796/memory-management-in-c">Memory 
Management in C++</a>, I am starting to explore this arena. Perhaps creating a 
custom Exception class wasn&#39;t such a good idea; I&#39;m forgetting the cardinal rule 
that you don&#39;t use it for program flow, although it sure does simplify my code 
(a sub-function throws an exception, and I don&#39;t have to code for various return 
values after each invocation of that sub-function). Not only that, but throwing 
exceptions makes it more likely that you&#39;ll end up with memory leaks. In fact, 
even as I&#39;m typing this I realize that I have foolishly failed to properly 
de-allocate a resource (see below; would have avoided this in C# through the 
<code>using (...)</code> construct). This Q&amp;A led me to do some searching on 
stack-allocated constructors, turning up
<a href="http://stackoverflow.com/questions/679571/when-to-use-new-and-when-not-to-in-c">
When to use "new" and when not to, in C++?</a>. Now I have some understanding of 
the lack of<em> new</em> in the exception-throwing.</p>
<pre class="brush: cpp">
HANDLE h = CreateFile(filePath, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE)
{
	throw MyException(filePath);
}
CloseHandle(h); // not de-allocated if the exception is thrown!
</pre>
<p>Alternately, I could wrap this all in a try/catch, add <code>CloseHandle(h)</code> into 
the catch and re-throw the exception. Or, I could simply put the <code>CloseHandle(h)</code> 
inside the <code>if</code> clause, before the <code>throw</code> statement.</p>
<p>Now I&#39;ve moved on to creating a DLL and linking that to my main executable, 
with the hard-coded values changed into class variables that have proper
<a href="http://stackoverflow.com/questions/760777/c-getters-setters-coding-style">
getters and setters</a> (didn&#39;t want to use the proprietary Properties offered 
by Microsoft). Running against a deadline, I may try to use this DLL from C# so 
that I can perform the file manipulation (splitting by 150,000) in familiar 
code. But how hard can it be to split a file in C++? Surely not too difficult. </p>
]]>
    </content>
</entry>

<entry>
    <title><![CDATA[Review and Reflection on &quot;The Mythical Man-Month&quot; by Frederick P. Brooks Jr.]]></title>
    <link rel="alternate" type="text/html" href="http://www.safnet.com/writing/tech/2011/11/review-and-reflection-on-the-mythical-man-month-by-frederick-p-brooks-jr.html" />
    <id>tag:www.safnet.com,2011:/writing/tech//3.441</id>

    <published>2011-11-10T03:05:44Z</published>
    <updated>2011-11-26T16:03:20Z</updated>

    <summary><![CDATA[Dr. Brooks is my new&hellip; well, I can&#39;t think of an appropriate noun. Certainly not a deity. One book does not make him a favorite tech author. Static text cannot make him a mentor. Maybe tech hero?...]]></summary>
    <author>
        <name>Stephen Fuqua</name>
        
    </author>
    
    <category term="mythicalmanmonth" label="Mythical Man-Month" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="review" label="Review" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.safnet.com/writing/tech/">
        <![CDATA[<p>Dr. Brooks is my new&hellip; well, I can&#39;t think of an appropriate noun. Certainly 
not a deity. One book does not make him a favorite tech author. Static text cannot make 
him a mentor. Maybe tech hero?</p>]]>
        <![CDATA[<p><em>The Mythical Man-Month </em>is a true classic. Many have heard of it; I 
wonder how many in my generation have taken the time to read it? Although it was 
written primarily* in the mid-seventies, based on experiences from the 
mid-sixties, it nevertheless offers</p>
<ol style="list-style-type: lower-alpha">
	<li>Brilliant insights on the working of computers and software;</li>
	<li>Brilliant insights on the workings of the people who work on them;</li>
	<li>Unintentional but illuminating lessons in history;</li>
	<li>A powerful argument for the importance of <em>process</em> but against 
	its ossification;</li>
	<li>And of course, much sage advice.</li>
</ol>
<p>(* the copy I found at a Half-Price is a 20th-anniversary edition with 
additional information, and valuable, essays written in the eighties and 
nineties).</p>
<p>This post will begin a  <a href="http://www.safnet.com/fcgi-bin/mt/mt-search.cgi?IncludeBlogs=3&tag=Mythical%20Man-Month&limit=20">series of reflections</a> based on little sticky notes I 
used to remind myself of Lessons Learned or To Be Explored. That in itself was a 
lesson learned, but from elsewhere. I had probably thought to do it before, but 
was too frugal to &quot;waste&quot; my sticky notes this way. Should&#39;ve been doing this 
for years.</p>]]>
    </content>
</entry>

<entry>
    <title>Design Updates and Fresh Content</title>
    <link rel="alternate" type="text/html" href="http://www.safnet.com/writing/tech/2011/10/design-updates-and-fresh-content.html" />
    <id>tag:www.safnet.com,2011:/tech//3.436</id>

    <published>2011-10-13T03:00:39Z</published>
    <updated>2011-11-05T15:27:56Z</updated>

    <summary>Currently I&#39;m working on updating the main blog at safnet.com with a refreshed look and feel (the design was last changed &quot;way back&quot; in 2008), then I&apos;ll move on to this technical blog. In the meantime, this garish built-in template...</summary>
    <author>
        <name>Stephen Fuqua</name>
        
    </author>
    
    
    <content type="html" xml:lang="en-us" xml:base="http://www.safnet.com/writing/tech/">
        <![CDATA[<p>Currently I&#39;m working on updating the main blog at safnet.com with a refreshed look and feel (the design was last 
changed "way back" in 2008), then
 I'll move on to this technical blog. In the meantime, this garish built-in template will serve to remind me
 that work needs to be done.</p>
 <p>New tech-blog entries have been rare primarily because I have been spending much of my technical-writing
 time on internal documentation at work: trying to build-up a thorough set of documentation in a SharePoint Wiki.
 Most of that content is proprietary, and would not be useful outside the company anyway. But I do hope
 to start posting comments here again soon, starting with a few entries after recently reading the classic 
 <i>The Mythical Man-Month</i>.</p>
]]>
        
    </content>
</entry>

<entry>
    <title>Protecting Against SQL Injection in Dynamic SQL Statements</title>
    <link rel="alternate" type="text/html" href="http://www.safnet.com/writing/tech/2011/02/protecting-agai.html" />
    <id>tag:www.safnet.com,2011:/writing/tech//3.432</id>

    <published>2011-02-26T17:42:16Z</published>
    <updated>2011-11-09T01:35:40Z</updated>

    <summary>Microsoft&#39;s Books Online article on SQL Injection does a great job of reviewing the possible attacks against dynamic SQL statements (using EXEC or sp_executesql). I won&apos;t re-hash their discussion and suggestions. What I offer below is a sample remediation effort...</summary>
    <author>
        <name>Stephen Fuqua</name>
        
    </author>
    
    <category term="security" label="security" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="sql" label="SQL" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.safnet.com/writing/tech/">
        <![CDATA[<p>Microsoft&#39;s Books Online article on <a href=
"http://msdn.microsoft.com/en-us/library/ms161953%28v=SQL.90%29.aspx">
SQL Injection</a> does a great job of reviewing the possible
attacks against dynamic SQL statements (using EXEC or
sp_executesql). I won't re-hash their discussion and suggestions.
What I offer below is a sample remediation effort for this set of
statements (the @Fields and @Values variables are actually stored
procedure parameters):</p>
<pre class="brush: sql">
DECLARE @Fields VARCHAR(1000), @VALUES VARCHAR(1000), @SQL NVARCHAR(2500);
SELECT @SQL = 'INSERT INTO MyTable (' + @Fields + ') VALUES (' + @Values + ')';
EXEC(@SQL);
</pre>]]>
        <![CDATA[<p>This represents the heart of what this stored procedure does. To
protect against SQL Injection, I first added a section of code that
checks to make sure that all of the fields in @Fields are real
fields &ndash; this is positive input validation:</p>
<pre class="brush: sql">
CREATE TABLE #temp (Field NVARCHAR(200)) 

INSERT INTO #temp(Field)
SELECT QUOTENAME(Field) FROM dbo.fnSplitString(@Fields,',')   

-- Validate that all fields are real fields in the table
IF EXISTS (SELECT  1 FROM #temp t WHERE NOT EXISTS
                     (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS c WHERE c.TABLE_NAME = 'MyTable'
                           AND QUOTENAME(c.COLUMN_NAME) = t.Field))
BEGIN
       DECLARE @v_strMessage AS NVARCHAR(500);

       SELECT @v_strMessage = 'Invalid  field(s) in the @Fields parameter detected: ';
       SELECT @v_strMessage = @v_strMessage  + QUOTENAME(t.Field) + ', '
            FROM #tempOrderField t WHERE NOT EXISTS
                           (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS c WHERE c.TABLE_NAME = 'MyTable'
                                  AND QUOTENAME(c.COLUMN_NAME) = QUOTENAME(t.Field));
       RAISERROR(@v_strMessage, 17, 0);
END
</pre>
<p>If there are any invalid fields, then they will all be listed in
an error message and the stored procedure will stop executing. Note
that all of the fields are note &ldquo;quoted&rdquo; by the
<code>QUOTENAME</code> function. Next, the @VALUES needs to be
protected. In this case, the application may send an apostrophe in
the data, legitimately. So I use the Replace statement twice
&ndash; once to guard against stray single quotes, and a second
time to overcome incorrectly doubled apostrophes.</p>
<pre class="brush: sql">
INSERT INTO #temp2 (Values)
SELECT REPLACE(REPLACE(Field, '''', ''''''), '''''', '''') FROM dbo.fnSplitString(@VALUES,',')
</pre>
<p>Finally, to avoid buffer overflows, I change the @SQL to
<code>NVARCHAR(MAX)</code>. In general it is better to use
<code>sp_executesql</code> instead of <code>EXEC</code>, so I also
change to that. In this case I can&rsquo;t benefit from it
(exercise for the reader to understand why), but I still use it out
of good habit.</p>
<pre class="brush: sql">
DECLARE @v_strSql NVARCHAR(MAX) -- statement needs 5028 characters, but to protect from buffer overflows, changing to MAX
SELECT @v_strSql = N'INSERT INTO dbo.MyTable ('

-- add  the fields
SELECT @v_strSql = @v_strSql + Field + ', ' FROM #temp;

-- remove extra comma and add VALUES()
SELECT @v_strSql = SUBSTRING(@v_strSql, 1, LEN(@v_strSql) - 1) + ') VALUES (';

-- add the values
SELECT @v_strSql = @v_strSql +  Value + ', ' FROM #temp2;

-- again remove extra comma and close VALUES()
SELECT @v_strSql = SUBSTRING(@v_strSql, 1, LEN(@v_strSql) - 1) + ');';

EXEC sp_executesql @v_strSql;
</pre>
<p>In summary, four changes were applied, as suggested by
Microsoft:</p>
<ul>
<li>Validated input data where I could (the field listing)</li>
<li>"Quoted" fields with <code>QUOTENAME</code> (can be done for
fields in INSERT, SELECT, ORDER BY, etc.)</li>
<li>Doubled-up on the apostrophes</li>
<li>Tried to protect against buffer overflow</li>
</ul>
<p>Before making these changes, I made sure that I had automated
unit tests that were passing with the old version. After updates,
and a few bug fixes, the unit tests are again passing. I also wrote
unit tests that included bad data to make sure everything still
worked fine.</p>]]>
    </content>
</entry>

<entry>
    <title>Explicit Column Mappings for SqlBulkCopy</title>
    <link rel="alternate" type="text/html" href="http://www.safnet.com/writing/tech/2011/01/explicit-column.html" />
    <id>tag:sfuqua2.pairserver.com,2011:/writing/tech//3.431</id>

    <published>2011-01-18T16:25:57Z</published>
    <updated>2011-09-27T19:19:28Z</updated>

    <summary><![CDATA[Recently, I received a code delivery that worked on our development server but failed in unit tests on my box. The culprit was a method that transformed a List&lt;T&gt; into a DataTable and used that DataTable to load data into...]]></summary>
    <author>
        <name>Stephen Fuqua</name>
        
    </author>
    
    <category term="c" label="c#" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="sqlbulkcopy" label="SqlBulkCopy" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.safnet.com/writing/tech/">
        <![CDATA[<p>Recently, I received a code delivery that worked on our development server but failed in unit tests on my box. The culprit was a method that transformed a <code>List&lt;T&gt;</code> into a <code>DataTable</code> and used that <code>DataTable</code> to load data into SQL Server using <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.aspx">SqlBulkCopy</a>. Lesson: apply column mappings.</p>]]>
        <![CDATA[<p>We went back and forth: &quot;it doesn't work,&quot; I reported. &quot;But it works on the dev server,&quot; says the developer. Can we both be right? I rebuild the code from my machine, where the unit test is not passing (due to an attempt to insert a value into a calculated column). Install on the dev server. Works without error.</p>
<p>Next day I'm reviewing another application that uses <code>SqlBulkCopy</code>. Another error. This time, data for one field is being inserted into another field. All along I suspected that the explicit ColumnMappings were needed. Now with a second data point, I went to look at the schema.</p>
<ul>
<li>On the dev server, the first table had the calculated column as the last field, but on mine the last two fields were flipped.</li>
<li>An older version of the second table&#39;s create script did not have an identity field. It exists in production, but if the corrected script were not loaded on the developer&#39;s unit testing database, then the field would be missing. It is the first field in the table.</li>
</ul>
<p>So, although I see nothing  stating this in the <a href="http://msdn.microsoft.com/en-us/library/434atets.aspx">documentation</a>, it appears that the order of the columns in the destination table matters. In fact, without explicitly mapping columns using the <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.columnmappings.aspx">ColumnMappings</a> property, the source and destination are matched by index, rather than column name. Thus if <code>Table1</code> is defined as <code>(Field1 varchar(10), Field2 varchar(10))</code> and it is loaded using <code>Object2 { string Field2; string Field1 }</code>, then the values loaded into the database will be flipped, <code>Object2.Field2 -&gt; Table1.Field1</code>. Add an explicit mapping and now it works.</p>]]>
    </content>
</entry>

<entry>
    <title>Review: Fundamental Modeling Concepts: Effective Communication of IT Systems</title>
    <link rel="alternate" type="text/html" href="http://www.safnet.com/writing/tech/2010/12/review-fundamen.html" />
    <id>tag:sfuqua2.pairserver.com,2010:/writing/tech//3.430</id>

    <published>2010-12-18T03:22:18Z</published>
    <updated>2011-11-20T16:33:47Z</updated>

    <summary>Fundamental Modeling Concepts: Effective Communication of IT Systems by Andreas Knopfel My rating: 3 of 5 stars I have mixed feelings about this book. I&apos;ve spent several years working diligently on my flow-charting capabilities, using what scan resources I could...</summary>
    <author>
        <name>Stephen Fuqua</name>
        
    </author>
    
    <category term="analysis" label="analysis" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="modeling" label="modeling" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="review" label="Review" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.safnet.com/writing/tech/">
        <![CDATA[<p><a href="http://www.goodreads.com/book/show/4000313-fundamental-modeling-concepts" style="float: left; padding-right: 20px"><img alt="Fundamental Modeling Concepts: Effective Communication of IT Systems" border="0" src="http://photo.goodreads.com/books/1266448029m/4000313.jpg" /></a><a href="http://www.goodreads.com/book/show/4000313-fundamental-modeling-concepts">Fundamental Modeling Concepts: Effective Communication of IT Systems</a> by <a href="http://www.goodreads.com/author/show/1705367.Andreas_Knopfel">Andreas Knopfel</a><br/>
My rating: <a href="http://www.goodreads.com/review/show/125379173">3 of 5 stars</a></p>
<p>I have mixed feelings about this book. I've spent several years working diligently on my flow-charting capabilities, using what scan resources I could easily and quickly sift through on the Web and in the Visio Help, studying the charts in all the comp-sci books I've read, and garnering feedback from my colleagues. This book might have sped up that process significantly, and has already had a positive impact on the communication efficacy of my charts. But, I simply didn't  completely like the specific modeling "language" presented by the authors.</p>]]>
        <![CDATA[<p> The flow charting is good, though I prefer having a few more block types to illustrate the type of data being dealt with (i.e. documents vs databases). The petri net was interesting but seemed like overkill -- when that level of detail is needed, then it is probably time to move into UML. But my experience is limited; I certainly don't know what others would find. And then there's the entity diagramming (ERD), which was simply non-standard. Too much space was dedicated to the fine details of the mechanics of these three viewpoints on modeling, although I suppose that would be appropriate for  anyone trying to use them as such and with little prior familiarity with flowchart or UML modeling.</p>
<p>The second half of the book moves beyond mechanics, and it is the more powerful portion. For it is there that we dive in to application, learning how the authors think and approach problems (most of which are in the domain of computing, but allusions are made to uses for other industries). The second half is also home to rare and valuable discussions of style, consistency, and simple communication. I suspect I shall return to the second half many times in coming years, looking for tips and reminders that will further improve the architectural models I build.</p>
<p>Recommended for: system architecture modeling and business analysis. Not recommended for: application design modeling. Even the authors agree that you should stick with UML for design of particular applications.</p>]]>
    </content>
</entry>

<entry>
    <title>What about this &quot;agile&quot; thing?</title>
    <link rel="alternate" type="text/html" href="http://www.safnet.com/writing/tech/2010/11/what-about-this.html" />
    <id>tag:sfuqua2.pairserver.com,2010:/writing/tech//3.429</id>

    <published>2010-11-12T03:37:09Z</published>
    <updated>2011-09-27T19:19:28Z</updated>

    <summary>A friend just wrote to me, asking about agile. He&apos;s been seeing software job posting with the vague request/promise of &quot;agile&quot; in them, wondering what the big deal is. Initial reaction: if no specific methodology or agile principle is cited,...</summary>
    <author>
        <name>Stephen Fuqua</name>
        
    </author>
    
    <category term="agile" label="agile" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.safnet.com/writing/tech/">
        <![CDATA[<p>A friend just wrote to me, asking about agile. He's been seeing software job posting with the vague request/promise of "agile" in them, wondering what the big deal is. Initial reaction: if no specific methodology or agile principle is cited, then at worst they are glomming on to pop culture, at best they want to make sure you can (a) handle changing requirements, (b) deliver prototypes and/or working code frequently, (c) take an iterative approach to documentation, coding, and testing.</p>
<p>
"Being agile" means both that you aren't going to freak out at the lack of a locked-down, step-by-step waterfall process, and that you aren't going to go cowboy and give the client a product at the last minute, with no conversations or demonstrations between the initial requirements "gathering" and delivery.
</p>]]>
        
    </content>
</entry>

<entry>
    <title>What about uint?</title>
    <link rel="alternate" type="text/html" href="http://www.safnet.com/writing/tech/2010/08/what-about-uint.html" />
    <id>tag:sfuqua2.pairserver.com,2010:/writing/tech//3.428</id>

    <published>2010-08-19T01:38:01Z</published>
    <updated>2011-11-09T01:40:03Z</updated>

    <summary>I&#39;m writing a class with several methods that take integer input. The input values cannot be less than zero. Since we&#39;re not on .Net 4.0 yet, I&#39;m manually writing code contracts (that is, my functions check preconditions, e.g. before doing...</summary>
    <author>
        <name>Stephen Fuqua</name>
        
    </author>
    
    <category term="c" label="c#" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="coding" label="coding" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.safnet.com/writing/tech/">
        <![CDATA[<p>I&#39;m writing a class with several methods that take integer input. The input values cannot be less than zero. Since we&#39;re not on .Net 4.0 yet, I&#39;m manually writing code contracts (that is, my functions check preconditions, e.g. before doing anything else, I write something like&hellip;</p>
<pre class="brush: csharp">
if (sequenceNumber < 0)
{
    throw new ArgumentOutOfRangeException("sequenceNumber", "Sequence number must be 0 or greater");
}
</pre>
<p>This got me thinking: why don&#39;t we ever use unsigned integers? Seems like having a uint would better communicate the requirement, and would simply not allow a negative number.  The <a href="http://stackoverflow.com/questions/2013116/should-i-use-uint-in-c-for-values-that-cant-be-negative">main answer</a> seems to be that casting between uint and other data types, which is inevitable, is ugly. And that uint is not CLS compliant. Even though I'm not trying to write CLS-compliant code at the moment, I think I'll stick with int &ndash; because that is our existing convention, and I don't see enough reason to change the convention.</p>]]>
        
    </content>
</entry>

</feed>

