<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Adam J Wolf]]></title>
  <link href="http://www.adamjwolf.com/atom.xml" rel="self"/>
  <link href="http://www.adamjwolf.com/"/>
  <updated>2012-01-24T19:11:20-07:00</updated>
  <id>http://www.adamjwolf.com/</id>
  <author>
    <name><![CDATA[Adam J Wolf]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Flexing your PEX]]></title>
    <link href="http://www.adamjwolf.com/blog/2012/01/20/flexing-your-pex/"/>
    <updated>2012-01-20T16:38:00-07:00</updated>
    <id>http://www.adamjwolf.com/blog/2012/01/20/flexing-your-pex</id>
    <content type="html"><![CDATA[<p><img src="http://www.adamjwolf.com/images/PostImages/pexweb.png" title="Pex Web" alt="Pex from Microsoft Research" /></p>

<p>It&#8217;s not what you think, exactly, but close. I have been interviewing again, this time for a full time position. During my search, on one of the interviews, I was asked to use the PEX coding for fun <a href="http://www.pexforfun.com/" title="Coding for fun">website</a> to flex my programming muscles.</p>

<!-- more -->


<p>If you don&#8217;t know about the Microsoft Research project, you can get more info at <a href="http://research.microsoft.com/en-us/projects/pex/" title="PEX">PEX</a>. Pex finds interesting input-output values of your methods, which you can save as a small test suite with high code coverage.</p>

<p>So Pex basically creates unit tests by sending in arguments to a method and compares the results to the expected output. It&#8217;s a neat piece of software. Here was my code challenge:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>using System;
</span><span class='line'> 
</span><span class='line'>public class Program {
</span><span class='line'>  public static int Puzzle(int x) {
</span><span class='line'>    // Can you write code to solve the puzzle? Ask Pex to see how close you are.
</span><span class='line'>    return x;
</span><span class='line'>  }
</span><span class='line'>}</span></code></pre></td></tr></table></div></figure>


<p>When you run it, Pex tells you the x parameter value and if the return value was correct. My solution was x * ((x * 2) - 1). Not too hard, but my interviewers threw me a curve ball when they also gave me the windows calculator on the scientific settings. I thought it was going to be some MOD square root nonsense.</p>

<p>I was really impressed with this approach to interviewing and the use of PEX. It might have been simpler to code up some unit test to a console program but the geeky-ness of their solution won me over. I was offered the position but did not accept it.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[TIP: Testing in Production]]></title>
    <link href="http://www.adamjwolf.com/blog/2012/01/10/tip-testing-in-production/"/>
    <updated>2012-01-10T16:09:00-07:00</updated>
    <id>http://www.adamjwolf.com/blog/2012/01/10/tip-testing-in-production</id>
    <content type="html"><![CDATA[<div style="clear:both">
  <img src="http://www.adamjwolf.com/images/PostImages/TIP.jpg" alt="Testing in Production">
</div>


<!-- more -->


<h2>If a bank employee posted this image on their cube for everyone to see, would you be concerned?</h2>

<p>He writes software that touches your checking account! Not so funny now is it! The older I get, the less I like surprises. I don&#8217;t know if it&#8217;s a &#8220;Get off my Lawn&#8221; thing or if I am getting old and crotchety. Or both. Putting untested code into production is something this developer never wants to do again. Ever. I have better things to do with my life.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[2011: A Year End Review]]></title>
    <link href="http://www.adamjwolf.com/blog/2011/12/30/2011-a-year-end-review/"/>
    <updated>2011-12-30T16:13:00-07:00</updated>
    <id>http://www.adamjwolf.com/blog/2011/12/30/2011-a-year-end-review</id>
    <content type="html"><![CDATA[<p>1 year, 12 months, 52 weeks, 365 days, 8,760 hours, 525,600 minutes, 31,536,000 seconds and for once, I am happy with the way I spent them. Most years I look back and think &#8220;I should have done better&#8221; but not this year. Satisfaction with everything is easier to attain when the bar is not perfection.</p>

<p>For me perfection was debilitating and would keep me from finishing, or worse, starting projects. My bright ideas were perfect until they were brought into the light. That&#8217;s usually when my drive to finish a project would wain or completely fail me. So to help me avoid my need for perfection, I made sure that I produce something. Even if it was a total pile.</p>

<p>Produce I did.</p>

<!-- more -->


<h2>Professional Accomplishments</h2>

<h3>www.PrintToPress.com</h3>

<p>Is a vanity book printing website that takes PDF files and produces perfect bound books. These are the books that you find in the bookstore but better quality. Nice million color glossy front covers thanks to my c# skills and a mess of 2D drawing math. This project is not perfect but we have produced over 13K books in just a short 9 months. Profitable it&#8217;s not but fills a need in the publishing industry, and it does it well.</p>

<h3>www.Foojal.com</h3>

<p>Foojal was a food photo journaling application that allowed people with camera phones to take pictures of their food to track how and what they ate. The site is no longer up but the code for the whole site has been open sourced and placed under my Github account for all to see and use. The site was a challenge because I coded it in Python using WSGI stack on Google Appengine. It was a wonderful learning experience and it&#8217;s not perfect.</p>

<h3>Wells Fargo and NRT</h3>

<p>I have a dirty little secret, I love Microsoft WCF. I don&#8217;t know what it is but I love connected systems. Most of my employers know this secret and Wells put me to work writing a cross platform web service for their PeoleSoft HR data. The best part was getting an email that the Mainframe can connect and successfully use the service. Yes the Mainframe!</p>

<h2>Personal Accomplishments</h2>

<h3>Motorcycle</h3>

<p>For as long as I can remember I have wanted to ride, so this year I did it. I have taken and passed the Riders Edge course put on by my local Harley Davidson motorcycle dealer and I am the proud owner of a new Honda Phantom. I love riding and in Arizona I have plenty of days to ride it. Even in the winter.</p>

<h3>Concealed Carry</h3>

<p>My uncle used to take me to the range near where we lived. The only problem was I was a better shot than he was. I guess it&#8217;s hard on a man when a 13 year old can shoot repeatedly through a bullseye at 30 feet and he can&#8217;t. I tell people that duck hunt was my teacher. One of the nice things about living in Arizona is all of the freedoms a citizen in good standing has. One of them being the right to carry and bear arms. So after some lengthy training I now have my concealed carry permit. I love putting little holes through paper at 30 feet. No, I do not carry all the time, especially not at work.</p>

<p>Well that&#8217;s enough tootin my own horn. 2011 was a great year and 2012 is shaping up to be very productive albeit not a perfect year.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Octopress: Blogging with 8 Arms at the Hub]]></title>
    <link href="http://www.adamjwolf.com/blog/2011/12/27/octopress-blogging-with-8-arms-at-the-hub/"/>
    <updated>2011-12-27T17:26:00-07:00</updated>
    <id>http://www.adamjwolf.com/blog/2011/12/27/octopress-blogging-with-8-arms-at-the-hub</id>
    <content type="html"><![CDATA[<p>Yes, I switch my blog again for the 10th time. Now with more awesomeness. The combination of Octopress, a heavily customized Jekyll static site generator with some sass and compass CSS wizardry.  The best part of Qctopress is the ease in which I can deploy the static site to GitHub to get some free hosting.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Dangerous Recurring Background Tasks]]></title>
    <link href="http://www.adamjwolf.com/blog/2010/11/14/dangerous-recurring-background-tasks/"/>
    <updated>2010-11-14T00:00:00-07:00</updated>
    <id>http://www.adamjwolf.com/blog/2010/11/14/dangerous-recurring-background-tasks</id>
    <content type="html"><![CDATA[<p>It’s funny how the same topics keep coming up over and over again. The other day I wrote about batch processing in Asp.net and today a college forwards me an article about “The Dangers of Implementing Recurring Background Tasks in Asp.Net” from Phil Haack.</p>

<blockquote><p>Warning: Phil, I am going to give you some grief, but you are awesome. How can you not be with Asp.Net MVC.</p></blockquote>

<p>Phil is a Senior Program Manager at Microsoft and Mr. Asp.Net MVC. A good guy, but I find it funny when you comment on your blog like this:</p>

<div style="clear:both">
    <img src="http://www.adamjwolf.com/images/Phil-hack-comment.png" alt="Phil-hack-comment">
</div>


<p>I run Microsoft OS’s with Microsoft IIS and program websites with Microsoft languages and frameworks but can’t do reoccurring tasks without punting out of the web project and into Windows Services or console programs. Don’t get me wrong Phil, I know you are busy but what the heck! Where is the worker role from Azure?</p>

<p>I suspect that Microsoft can figure out how to give it&#8217;s most popular development server (IIS) the ability to do batch processing. How can IIS in its 7th version not have the same features as Azure beta or AppEngine from Google? Can you say Cron.yaml?</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[C# Static Cancer]]></title>
    <link href="http://www.adamjwolf.com/blog/2010/11/10/static-cancer/"/>
    <updated>2010-11-10T00:00:00-07:00</updated>
    <id>http://www.adamjwolf.com/blog/2010/11/10/static-cancer</id>
    <content type="html"><![CDATA[<p>How do you turn an object orientated language like C# into a procedural language like COBOL? That’s right you make everything static. On a current project we have a business DLL with 39 code files and 412 instances of the static keyword. That’s +10 per code file. Here is the screen shot from Visual Studio 2010.</p>

<div style="clear:both">
    <img src="http://www.adamjwolf.com/images/Static-cancer.png" alt="Static Cancer">
</div>


<p>You might be asking “What’s wrong with this?” and if you like spaghetti the answer is nothing. Some people say that object orientated code is complicated because of the hiding of implementation in base class’s obscures what the program does, but I can also argue that seeing all of the implementation details in static classes obscures the forest because of the trees. Either way, too far to the left or right and you will have issues. A more moderate approach is swinging between the paradigms and choosing the correct design techniques.</p>

<p>Choosing between static and instance methods is a matter of object-oriented design. If the method you are writing is a behavior of an object, then it should be an instance method. If it doesn&#8217;t depend on an instance of an object, it should be static. Remember, testing static methods that have dependencies are notoriously difficult to isolate and Unit test.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[The Mainframe Gives Me Hope]]></title>
    <link href="http://www.adamjwolf.com/blog/2010/11/07/the-mainframe-gives-me-hope/"/>
    <updated>2010-11-07T00:00:00-07:00</updated>
    <id>http://www.adamjwolf.com/blog/2010/11/07/the-mainframe-gives-me-hope</id>
    <content type="html"><![CDATA[<p>I am 38 and I love what I do. Later in life will I still be developing? This may shock you but the mainframe gives me hope. Have you ever walked through a mainframe development department lately? Well I have, and I must tell you it’s grey. Yep, that’s right grey hair or if fate has been cruel to you no hair.</p>

<p>You might be asking why where you walking through a mainframe department. Well it’s a funny story. One day an architect on my team came over to my desk and said he needed me to help a team connect to one of our existing web services. That’s right; he walked me right into the mainframe developer’s lair. It was surreal. I am thinking to myself how do I get a dinosaur to drive a Prius?  My architect introduced me to a gentleman that could have been old enough to be my grandfather and abruptly left.</p>

<p>After some awkward questions like, do you use SOAP? Can the mainframe understand XML? Do you have a SOAP client or are you going to submit xml blobs with replaced sections? I was amazed when they said “yes we use SOAP and have a client for the mainframe”, I thought of that Prius with a dinosaur driving down the street.</p>

<p>At my grandfather’s age will I still be coding? I hope so and now I have hope because of the mainframe and there developers. Live long enough and the world will surprise you. Here’s to the mainframe, long live the mainframe!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Interview Questions]]></title>
    <link href="http://www.adamjwolf.com/blog/2010/10/14/the-interview/"/>
    <updated>2010-10-14T00:00:00-07:00</updated>
    <id>http://www.adamjwolf.com/blog/2010/10/14/the-interview</id>
    <content type="html"><![CDATA[<p>Part of my job at many clients has been interviewing new candidates. It&#8217;s a thankless job, that if not done well, can cost you and your client dearly. All of us have had the torturous interviews with Google searching morons that ask you questions like how is a hash table implemented, to which I respond &#8220;I don&#8217;t care if it works.&#8221;</p>

<p>There are two different types of interview questions, the specific and the general. Questions like &#8220;What color do you get when you add blue and yellow together&#8221; will only tell you they know how to make green. A better question is &#8220;How do you use a color wheel.&#8221; Can you see the difference?</p>

<p>When I interview a candidate for a position, I use a set of questions that dips or tunnels into the specifics on their knowledge and background. Here is an example:</p>

<blockquote><p>How many lines in an Asp.Net code behind file is too many?</p></blockquote>

<p>If they answer with something reasonable like 200 lines, then I would move on. If not, then you might have other questions.</p>

<blockquote><p>How would you break up a code behind file to be smaller?</p></blockquote>

<p>Again, hopefully, they say something about user controls and breaking up the functionality on the page and not move the hard coded injection flawed SQL queries from the code behind. Then you can dig a little deeper and ask something harder like:</p>

<blockquote><p>How do you communicate from one user control to another or to the host page?</p></blockquote>

<p>If they answer this last question correctly, you know that they know what&#8217;s going on in Asp.Net and not that they have memorized the page lifecycle. Did you notice who would have to do most of the talking? That&#8217;s right, the candidate. You can pick up a lot from these conversations.</p>

<h3>Here are a few more conversation starters</h3>

<ul>
<li>How can you throttle WCF service calls from a specific client?</li>
<li>What&#8217;s your take on ORM&#8217;s good and bad?</li>
<li>What blogs or books have you read in the last three months?</li>
<li>What would you like to learn next?</li>
<li>How can you share data from one website to the other?</li>
</ul>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Batch Processing in ASP.Net]]></title>
    <link href="http://www.adamjwolf.com/blog/2010/10/05/batch-processing-in-aspnet/"/>
    <updated>2010-10-05T00:00:00-07:00</updated>
    <id>http://www.adamjwolf.com/blog/2010/10/05/batch-processing-in-aspnet</id>
    <content type="html"><![CDATA[<p>So you need to do some work that is not a logical part of a web request and you are looking for options. Well, we got options and a lot of questions.</p>

<ul>
<li>Do you need it to process all the time. Will recycling the app pool cause you pain?</li>
<li>Is it truly batch processing or processing a lot of items?</li>
<li>Are you on shared hosting?</li>
<li>Can you install a service?</li>
<li>Will your processing demands spike periodically?</li>
<li>Have more than one node?</li>
<li>Can you put an executable on the box?</li>
<li>Can you use the windows Task scheduler?</li>
<li>Thought of moving to Azure or App engine?</li>
</ul>


<p>Ok, all kidding aside, some of these questions have real impact on how good your batch processing job will perform and how often you will be babysitting it. For a simple site with a small batch processing need, I would use the old timer trick in a http module right in the web site.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">public</span> <span class="k">class</span> <span class="nc">BatchModule</span> <span class="p">:</span> <span class="n">IHttpModule</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'>  <span class="k">protected</span> <span class="k">static</span> <span class="n">Timer</span> <span class="n">_timer</span> <span class="p">=</span> <span class="k">null</span><span class="p">;</span>
</span><span class='line'>  
</span><span class='line'>  <span class="k">public</span> <span class="k">void</span> <span class="nf">Init</span><span class="p">(</span><span class="n">HttpApplication</span> <span class="n">application</span><span class="p">)</span>
</span><span class='line'>  <span class="p">{</span>
</span><span class='line'>      <span class="k">if</span> <span class="p">(</span><span class="n">_timer</span> <span class="p">==</span> <span class="k">null</span><span class="p">)</span>
</span><span class='line'>      <span class="p">{</span>
</span><span class='line'>          <span class="n">var</span> <span class="n">timerCallback</span> <span class="p">=</span> <span class="k">new</span> <span class="n">TimerCallback</span><span class="p">(</span><span class="n">DoWork</span><span class="p">);</span>
</span><span class='line'>          <span class="n">_timer</span> <span class="p">=</span> <span class="k">new</span> <span class="n">Timer</span><span class="p">(</span><span class="n">timerCallback</span><span class="p">,</span> <span class="k">null</span><span class="p">,</span> <span class="m">10000</span><span class="p">,</span> <span class="m">60000</span><span class="p">);</span>
</span><span class='line'>      <span class="p">}</span>
</span><span class='line'>  <span class="p">}</span>
</span><span class='line'>  
</span><span class='line'>  <span class="k">public</span> <span class="k">void</span> <span class="nf">DoWork</span><span class="p">(</span><span class="kt">object</span> <span class="n">state</span><span class="p">)</span>
</span><span class='line'>  <span class="p">{</span>
</span><span class='line'>      <span class="c1">//do something</span>
</span><span class='line'>  <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>This technique has many issues and should only be used for the simplest things. Some issues include the app pool recycling and shutting down your batch processor. Others include having to make your processing code reentrant.</p>

<p>If I was asked today to do batch processing for a client, I would use a Windows Service with WCF backed by MSMQ or some other distributed asynchronous message system that would scale when nodes are added to the cluster. Even if this app was run on a single server, I would still use a local MSMQ queue to start. The atomic way that MSMQ distributes messages and the benefits of throttling, discreet work packets, dead lettering and scalability outweigh the initial complexity of the solution.</p>

<p>There are many platforms today that make batch jobs easier like Azure worker roles, AppEngine and Heroku, not to mention, cron on Unix platforms. I know about the Windows Scheduler and the pain of using it in production. I was hoping that Microsoft would add the worker role functionality to IIS and Asp.Net but it does not look like the cool app fabric features will be coming to IIS.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[WCF Dynamic IP Filtering]]></title>
    <link href="http://www.adamjwolf.com/blog/2010/10/04/wcf-dynamic-ip-filtering/"/>
    <updated>2010-10-04T00:00:00-07:00</updated>
    <id>http://www.adamjwolf.com/blog/2010/10/04/wcf-dynamic-ip-filtering</id>
    <content type="html"><![CDATA[<p>Have you ever had a client that wanted to do dynamic time of day IP filtering of a WCF service? No! What do you live under, a rock?</p>

<p>Well, I have and this is how I solved it. First, we look for better options like not writing code and use IIS IP Filtering. After that&#8217;s rejected by the client, I fire up my IDE; it takes so loooong.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
<span class='line-number'>36</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">public</span> <span class="k">class</span> <span class="nc">IPFilteringAuthorizationManager</span> <span class="p">:</span> <span class="n">ServiceAuthorizationManager</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'>  <span class="k">private</span> <span class="k">const</span> <span class="kt">string</span> <span class="n">ServiceActionAttempedBy</span> <span class="p">=</span> <span class="s">&quot;{0} Service Action {1} attemped by {2}.&quot;</span><span class="p">;</span>
</span><span class='line'>  <span class="k">private</span> <span class="k">const</span> <span class="kt">string</span> <span class="n">NoAuthorizedIPAddress</span> <span class="p">=</span> <span class="s">&quot;{0} is not an authorized IP address for {1}.&quot;</span><span class="p">;</span>
</span><span class='line'>  <span class="k">private</span> <span class="k">const</span> <span class="kt">string</span> <span class="n">AuthorizationManagerFailure</span> <span class="p">=</span> <span class="s">&quot;ARTServiceAuthorizationManager failure.&quot;</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'>  <span class="k">protected</span> <span class="k">override</span> <span class="kt">bool</span> <span class="nf">CheckAccessCore</span><span class="p">(</span><span class="n">OperationContext</span> <span class="n">operationContext</span><span class="p">)</span>
</span><span class='line'>  <span class="p">{</span>
</span><span class='line'>      <span class="n">var</span> <span class="n">callerIsAuthorized</span> <span class="p">=</span> <span class="k">false</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'>      <span class="n">var</span> <span class="n">callersIP</span> <span class="p">=</span> <span class="p">((</span><span class="n">RemoteEndpointMessageProperty</span><span class="p">)</span><span class="n">operationContext</span>
</span><span class='line'>          <span class="p">.</span><span class="n">IncomingMessageProperties</span><span class="p">[</span><span class="n">RemoteEndpointMessageProperty</span><span class="p">.</span><span class="n">Name</span><span class="p">]).</span><span class="n">Address</span><span class="p">;</span>
</span><span class='line'>      <span class="n">var</span> <span class="n">mesageTo</span> <span class="p">=</span> <span class="n">operationContext</span><span class="p">.</span><span class="n">RequestContext</span><span class="p">.</span><span class="n">RequestMessage</span><span class="p">.</span><span class="n">Headers</span><span class="p">.</span><span class="n">To</span><span class="p">.</span><span class="n">Segments</span><span class="p">.</span><span class="n">Last</span><span class="p">();</span>
</span><span class='line'>      <span class="n">var</span> <span class="n">messageAction</span> <span class="p">=</span> <span class="n">operationContext</span><span class="p">.</span><span class="n">RequestContext</span><span class="p">.</span><span class="n">RequestMessage</span><span class="p">.</span><span class="n">Headers</span><span class="p">.</span><span class="n">Action</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'>      <span class="k">try</span>
</span><span class='line'>      <span class="p">{</span>
</span><span class='line'>          <span class="n">callerIsAuthorized</span> <span class="p">=</span> <span class="n">GetAuthorizedIPAddresses</span><span class="p">(</span><span class="n">mesageTo</span><span class="p">).</span><span class="n">Contains</span><span class="p">(</span><span class="n">callersIP</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'>          <span class="k">if</span> <span class="p">(!</span><span class="n">callerIsAuthorized</span><span class="p">)</span>
</span><span class='line'>          <span class="p">{</span>
</span><span class='line'>              <span class="n">_log</span><span class="p">.</span><span class="n">Info</span><span class="p">(</span><span class="n">String</span><span class="p">.</span><span class="n">Format</span><span class="p">(</span><span class="n">NoAuthorizedIPAddress</span><span class="p">,</span> <span class="n">callersIP</span><span class="p">,</span> <span class="n">mesageTo</span><span class="p">));</span>
</span><span class='line'>          <span class="p">}</span>
</span><span class='line'>      <span class="p">}</span>
</span><span class='line'>      <span class="k">catch</span> <span class="p">(</span><span class="n">Exception</span> <span class="n">ex</span><span class="p">)</span>
</span><span class='line'>      <span class="p">{</span>
</span><span class='line'>          <span class="n">_log</span><span class="p">.</span><span class="n">Error</span><span class="p">(</span><span class="n">ex</span><span class="p">);</span>
</span><span class='line'>      <span class="p">}</span>
</span><span class='line'>      <span class="k">finally</span>
</span><span class='line'>      <span class="p">{</span>
</span><span class='line'>          <span class="n">_log</span><span class="p">.</span><span class="n">Info</span><span class="p">(</span><span class="n">String</span><span class="p">.</span><span class="n">Format</span><span class="p">(</span><span class="n">ServiceActionAttempedBy</span><span class="p">,</span> <span class="n">mesageTo</span><span class="p">,</span> <span class="n">messageAction</span><span class="p">,</span> <span class="n">callersIP</span><span class="p">));</span>
</span><span class='line'>      <span class="p">}</span>
</span><span class='line'>
</span><span class='line'>      <span class="k">return</span> <span class="n">callerIsAuthorized</span><span class="p">;</span>
</span><span class='line'>  <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>I am a big fan of how WCF can be composed so I used a ServiceAuthorizationManager and added it to the services behaviors through the config.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
</pre></td><td class='code'><pre><code class='xml'><span class='line'><span class="nt">&lt;serviceBehaviors&gt;</span>
</span><span class='line'>  <span class="nt">&lt;behavior</span> <span class="na">name=</span><span class="s">&quot;IPFilteringBehavior&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>      <span class="nt">&lt;serviceMetadata</span> <span class="na">httpGetEnabled=</span><span class="s">&quot;true&quot;</span><span class="nt">/&gt;</span>
</span><span class='line'>      <span class="nt">&lt;serviceDebug</span> <span class="na">includeExceptionDetailInFaults=</span><span class="s">&quot;false&quot;</span><span class="nt">/&gt;</span>
</span><span class='line'>      <span class="nt">&lt;serviceAuthorization</span>
</span><span class='line'>          <span class="na">serviceAuthorizationManagerType=</span><span class="s">&quot;AdamJWolf.IPFilteringAuthorizationManager, </span>
</span><span class='line'><span class="s">              AdamJWolf.Core, </span>
</span><span class='line'><span class="s">              Version=1.0.0.0, </span>
</span><span class='line'><span class="s">              Culture=neutral, </span>
</span><span class='line'><span class="s">              PublicKeyToken=null&quot;</span> <span class="nt">/&gt;</span>
</span><span class='line'>  <span class="nt">&lt;/behavior&gt;</span>
</span><span class='line'><span class="nt">&lt;/serviceBehaviors&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<p>I left out the boring part about which IP addresses are allowed and at what time, but I think you get the point. These dynamic rules for access to a WCF service can get a little sticky but WCF has some great extensibility points that allow you to solve your client&#8217;s problems. I have also used the same type of dynamic service authorization for use with Active Directory Groups.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Syntax is my UI Mascot]]></title>
    <link href="http://www.adamjwolf.com/blog/2010/10/03/syntax-is-my-ui-mascot/"/>
    <updated>2010-10-03T00:00:00-07:00</updated>
    <id>http://www.adamjwolf.com/blog/2010/10/03/syntax-is-my-ui-mascot</id>
    <content type="html"><![CDATA[<p>Every team should have a mascot and Syntax is my UI has Syni. Syni is of my own design and will be making appearances in articles in the future. I hope you enjoy him.</p>

<p><img src="http://www.adamjwolf.com/images/Syni-angel.png" width="100" height="100" alt="Syni Angel">
<img src="http://www.adamjwolf.com/images/Syni-apple.png" width="100" height="100" alt="Syni Apple">
<img src="http://www.adamjwolf.com/images/Syni-black.png" width="100" height="100" alt="Syni Black">
<img src="http://www.adamjwolf.com/images/Syni-coder.png" width="100" height="100" alt="Syni Coder">
<img src="http://www.adamjwolf.com/images/Syni-Mad.png" width="100" height="100" alt="Syni Mad">
<img src="http://www.adamjwolf.com/images/Syni-microsoft.png" width="100" height="100" alt="Syni Microsoft">
<img src="http://www.adamjwolf.com/images/Syni-product.png" width="100" height="100" alt="Syni Product">
<img src="http://www.adamjwolf.com/images/Syni-ruby.png" width="100" height="100" alt="Syni Ruby">
<img src="http://www.adamjwolf.com/images/Syni-Suprized.png" width="100" height="100" alt="Syni Suprized">
<img src="http://www.adamjwolf.com/images/Syni.png" width="100" height="100" alt="Syni"></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Where did the Syntax is my Ui tagline come from?]]></title>
    <link href="http://www.adamjwolf.com/blog/2010/10/02/where-did-syntax-is-my-ui/"/>
    <updated>2010-10-02T00:00:00-07:00</updated>
    <id>http://www.adamjwolf.com/blog/2010/10/02/where-did-syntax-is-my-ui</id>
    <content type="html"><![CDATA[<p>Where did the &#8220;Syntax is my Ui&#8221; tagline come from? The name came from a presentation on CoffeeScript where the user interface of the CoffeeScript language was compared to the JavaScript language. The video was enlightening. I was struck by the realization that it&#8217;s true and took it as my mantra and tagline. No matter how slick the user interface is, what really matters is the syntax. Whether I am programming or writing documents, the words are the real user interface.</p>

<p>The presentation shows how some language designers understand that the user experience of a language is just as important as run-time performance. Just take a look at how Ruby and CoffeeScript have been designed for developer happiness and not the machine. After programming in Ruby and Python, now I constantly leave off the semicolon in C#. Why can&#8217;t the compiler do this for me?</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Welcome to my Thoughts]]></title>
    <link href="http://www.adamjwolf.com/blog/2010/10/01/welcome-to-my-thoughts/"/>
    <updated>2010-10-01T00:00:00-07:00</updated>
    <id>http://www.adamjwolf.com/blog/2010/10/01/welcome-to-my-thoughts</id>
    <content type="html"><![CDATA[<p>My thoughts are my own and my opinions will change based upon experience, reflection and new information. I believe in the principle of strong opinions, weakly held. These pages are a collection of my experiences, opinions and knowledge gained in the pursuit of software craftsmanship. I try not to take myself too seriously and will sometimes have fun exposing my mistakes on these pages. It is my hope that you enjoy the site and come back frequently.</p>

<p>If you disagree with me, then you must be thinking for yourself and that&#8217;s good. These pages will not have a feedback mechanism, but if you are so inclined, I would love to discuss your point of view over a diet coke. Please contact me by heavily spam filtered email.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Syni on a Mini]]></title>
    <link href="http://www.adamjwolf.com/blog/2010/03/01/siny-on-a-mini/"/>
    <updated>2010-03-01T00:00:00-07:00</updated>
    <id>http://www.adamjwolf.com/blog/2010/03/01/siny-on-a-mini</id>
    <content type="html"><![CDATA[<p>For those of you that know me, you are going to be shocked when I tell you that this WordPress site is being served from a Mac. A Mac Mini no less. That’s right; this site is served from a Mac Mini running Mac OSX Snow Leopard Server. You want to know what’s even more shocking? It was the easiest server and blog I have ever set up.</p>

<p>The server is sitting in a colo that deals with only Minis called Macminicolo.net. Not the most original name but the service and the customer support are top notch. After ordering the server, it was up and running in a day. Setting up the Apache web server for OSX is criminally easy. Check one box and Bam! servers ready. Eat your heart out IIS.</p>

<p>I have tried every known .net open source blog and let me tell you, WordPress beats them all, no questions. If you are serious about blogging, WordPress is the easiest and most feature rich blogging platform. Don’t waste your time with the others, just get WordPress up and running; you will never go back. The install of the database was a check box and some configuration.  The blog was a directory copy and editing one configuration file. Everything else was just admin stuff like user names and themes.</p>

<p>For all of you .Net Microsoft Kool-Aid drinkers out there, do me a favor and try something different like OSX, Apache, WordPress and MySql. What do you have to lose? Maybe some of that wool from over your eyes.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Single Responsibility Principle of a WCF Service]]></title>
    <link href="http://www.adamjwolf.com/blog/2010/02/01/SRP-WCF/"/>
    <updated>2010-02-01T00:00:00-07:00</updated>
    <id>http://www.adamjwolf.com/blog/2010/02/01/SRP-WCF</id>
    <content type="html"><![CDATA[<p>Ok, get ready, I am going to lay some knowledge on you that might one day save your WCF service. This guidance should be vetted and not taken as gospel. Think for yourself and apply this principle pragmatically.</p>

<p>Single Responsibility Principle (SRP) defined by <a href="http://en.wikipedia.org/wiki/Single_responsibility_principle">wikipedia</a></p>

<blockquote><p>Martin defines a responsibility as a reason to change, and concludes that a class or module should have one, and only one, reason to change. As an example, consider a module that compiles and prints a report. Such a module can be changed for two reasons. First, the content of the report can change. Second, the format of the report can change. These two things change for very different causes; one substantive, and one cosmetic. The single responsibility principle says that these two aspects of the problem are really two separate responsibilities, and should therefore be in separate classes or modules. It would be a bad design to couple two things that change for different reasons at different times.
<a href="http://www.amazon.com/gp/product/0131857258">Agile Software Development, Principles, Patterns, and Practices</a></p></blockquote>

<p>The single responsibility of a WCF service is to facilitate communication to the underlying business logic. A WCF service should take in messages, coordinate with delegates and return the results. That’s it, very simple, one responsibility. When applying SRP to a WCF service, we find the axis of possible change is when the service interface changes.</p>

<figure class='code'><figcaption><span>A pseudo WCF service</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">public</span> <span class="n">Foo</span> <span class="nf">DoSomething</span><span class="p">(</span><span class="n">Bar</span> <span class="n">a</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>
</span><span class='line'>    <span class="c1">// Validate</span>
</span><span class='line'>
</span><span class='line'>    <span class="c1">// Transform</span>
</span><span class='line'>
</span><span class='line'>    <span class="c1">// Act</span>
</span><span class='line'>
</span><span class='line'>    <span class="c1">// Transform</span>
</span><span class='line'>
</span><span class='line'>    <span class="c1">// Return</span>
</span><span class='line'>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>




<figure class='code'><figcaption><span>A more concrete example</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">public</span> <span class="n">Contact</span><span class="p">[]</span> <span class="nf">GetContacts</span><span class="p">(</span><span class="n">ContactCriteria</span> <span class="n">criteria</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>
</span><span class='line'>    <span class="k">if</span> <span class="p">(!</span><span class="n">criteria</span><span class="p">.</span><span class="n">isValid</span><span class="p">())</span> <span class="k">throw</span> <span class="k">new</span> <span class="n">InvalidCriteriaException</span><span class="p">();</span>
</span><span class='line'>
</span><span class='line'>    <span class="n">var</span> <span class="n">blackbook</span> <span class="p">=</span> <span class="k">new</span> <span class="n">AddressBook</span><span class="p">();</span>
</span><span class='line'>    <span class="n">var</span> <span class="n">entries</span> <span class="p">=</span>  <span class="n">blackbook</span><span class="p">.</span><span class="n">GetEntriesByCriteria</span><span class="p">(</span><span class="n">criteria</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'>    <span class="n">var</span> <span class="n">contacts</span> <span class="p">=</span> <span class="n">Converter</span><span class="p">.</span><span class="n">ToContacts</span><span class="p">(</span><span class="n">entries</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'>    <span class="k">return</span> <span class="n">contacts</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>This GetContacts method of the Contact service does not actually do anything except coordinate and delegate responsibilities to other objects. This service will be unaffected by changes in Contract, ContactCriteria, AddressBook, Converter and data access technique, allowing us to change them and not effect the service.</p>

<h3>Things that do not belong in a WCF service are</h3>

<ul>
<li>Business Logic</li>
<li>Validation Logic</li>
<li>Data Access Logic</li>
<li>Transformation Logic</li>
<li>Logging</li>
</ul>


<p>Adding any of the above items will greatly increase the chance of change and violate SRP.</p>

<h3>Things that do belong in a WCF service are</h3>

<ul>
<li>Service coordination Logic</li>
<li>SOAP fault Logic</li>
</ul>


<p>SRP will help you build systems that are more tolerant to change. That does not mean your service will be impervious to change just a little more nimble. We all know that 1.0 is just the first version of our system that will eventually change.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[No Version Control Options]]></title>
    <link href="http://www.adamjwolf.com/blog/2010/01/01/version-control/"/>
    <updated>2010-01-01T00:00:00-07:00</updated>
    <id>http://www.adamjwolf.com/blog/2010/01/01/version-control</id>
    <content type="html"><![CDATA[<p>Is version control optional? Yes, if you are just fooling around and you don’t care if your hard drive takes a permanent siesta. No, for everything else.</p>

<p>I remember when I started out developing some years ago and we did not have version control systems (VCS). I used to make backups on to floppy disks. Do I sound old? Today, we have so many good choices for VCS like <a href="http://en.wikipedia.org/wiki/Team_Foundation_Server">Team Foundation Server</a>, <a href="http://subversion.tigris.org/">SVN</a>, <a href="http://git-scm.com/" >Git</a> and <a href="http://mercurial.selenic.com" target="_blank"> Mercurial,</a> just to name a few. I envy the new people coming to this profession; no floppy disks required.</p>

<p>Now that we know we need a VCS, how should you go about picking one? Your choice is going to be dictated by what camp you belong to. If you’re in a Microsoft shop, then TFS might be a good choice due to the integration with Visual Studio. If you are in the Ruby / Rails camp, then you will probably use Git and Pythonist will choose Mercurial.   These are not hard and fast rules, just an observation from this floppy shuffler.</p>

<p>I use TFS at work and Git for everything else including this blog post. You know that version control is for more than code, right? I prefer Git, but for some using the command line, it’s not visual enough.  I also use <a href="http://www.projectlocker.com/" target="_blank">Project Locker</a>, a hosting service for SVN and Git repositories. Project locker gives me peace of mind knowing that my version control is under control and backed up regularly. You can also get remote Git repositories from <a href="http://github.com/" target="_blank">Github</a>.</p>

<p>So, what are you waiting for? Get your out of control assets into a version control system.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Freaking Out C# 2.0 Developers]]></title>
    <link href="http://www.adamjwolf.com/blog/2009/11/01/Freaking-out-csharp-developers/"/>
    <updated>2009-11-01T00:00:00-07:00</updated>
    <id>http://www.adamjwolf.com/blog/2009/11/01/Freaking-out-csharp-developers</id>
    <content type="html"><![CDATA[<p>Ok, what’s the deal with all the old timers bitching about people using the new features in C#? I’m not talking about C# 4.0 and the dynamic keyword. I am talking about 3.0/3.5, specifically lambdas, extension and anonymous methods. Oh, and you don’t want to get me started on all the var haters out there.</p>

<blockquote><p>Yes, extension methods are the devil, and one day, will come and eat your babies!</p></blockquote>

<h4>Extension Method Example ####</h4>

<div>
  <pre>
    <code class='csharp'>//Extension methods for logging
 
&quot;This is a message to log.&quot;.LogMessage();
 
new InvalidOperationException(&quot;You did a bad thing&quot;).LogException();</code>
  </pre>
</div>


<p>Yes, extension methods can get sticky when upgrading your app from one version of the .Net Framework to the next. How many times in your career have you upgraded a production app to a new framework version? I have, twice! You will be able to figure out if your extension methods conflict with a framework version in 30 min, tops.</p>

<p>You know my friend Action and his big brother Action&lt;T&gt; right? How about his cousin Func? If you said no, please stop reading and follow the links for an education. Delegates are powerful but for some reason they freak-out C# 2.0 developers.</p>

<h4>Anonymous Methods, Extensions and Lambdas, Oh My! ####</h4>

<div>
  <pre>
    <code class='csharp'>// Boolean extension methods
var HasMoney = true;
var WillGetPaid = true;
 
HasMoney.IsTrueThen(()=&gt; Debug.WriteLine(&quot;Spend Spend Spend.&quot;));
 
HasMoney.IsFalseThen(() =&gt; {
    Debug.WriteLine(&quot;Save your money.&quot;);
    Debug.WriteLine(&quot;Then spend your money.&quot;);
});
 
(HasMoney || WillGetPaid).IsTrueThen(() =&gt; Debug.WriteLine(&quot;Spend Spend
Spend.&quot;));</code>
  </pre>
</div>


<p>Combining all of these techniques can be a little overwhelming at first but chill out and read the code. Does it sound better? Is it more English like? Does it just roll of your tongue? Ok, so the ()=> is weirding you out. Well get used to the Lambda; it is here to stay. The ability to attach code blocks to event handlers and delegates is neat and all the cool kids are doing it. Come on, you know you want to try it. What’s it going to hurt, just one lambda?</p>

<p>Do you need to know these techniques to build software that your clients are going to love? No, you do not, but ignoring and avoiding them is like sticking your head in the sand. Part of being a craftsman is keeping your tools sharp and learning the features of your current language is part of sharpening the saw. So get back to work and learn the new and old features of C#.</p>
]]></content>
  </entry>
  
</feed>

