﻿<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Programming By A Tool</title>
	<atom:link href="http://byatool.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://byatool.com</link>
	<description>This is my recorded stumbling through ASP.Net, Framework 3.5, C# 3.0, Ajax, Javascript, and Love.  Stay, learn, destroy.  It's your life.</description>
	<lastBuildDate>Thu, 03 May 2012 17:28:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Coffeescript versus Javascript example for FUN</title>
		<link>http://byatool.com/coffeescript/coffeescript-versus-javascript-example-for-fun/</link>
		<comments>http://byatool.com/coffeescript/coffeescript-versus-javascript-example-for-fun/#comments</comments>
		<pubDate>Thu, 03 May 2012 17:28:21 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Coffeescript]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=2541</guid>
		<description><![CDATA[Coffeescript: window.someList = [1, 2, 3, 4, 5] addOne = (item) -&#62; 1 + item window.runThings = () -&#62; addOne item for item in someList Coffeescript compiled to JavaScript: (function() { var addOne; window.someList = [1, 2, 3, 4, 5]; addOne = function(item) { return 1 + item; }; window.runThings = function() { var item, [...]]]></description>
			<content:encoded><![CDATA[<h3>Coffeescript:</h3>
<pre><span style="color: #008080;">window</span>.someList = [1, 2, 3, 4, 5]

addOne = (item) -&gt;
  1 + item

<span style="color: #008080;">window</span>.runThings = () -&gt;
  addOne item <span style="color: #0000ff;">for</span> item <span style="color: #0000ff;">in</span> someList</pre>
<h3>Coffeescript compiled to JavaScript:</h3>
<pre>(function() {
  <span style="color: #0000ff;">var</span> addOne;
  <span style="color: #008080;">window</span>.someList = [1, 2, 3, 4, 5];
  addOne = function(item) {
    <span style="color: #0000ff;">return</span> 1 + item;
  };
  <span style="color: #008080;">window</span>.runThings = function() {
    <span style="color: #0000ff;">var</span> item, _i, _len, _results;
    _results = [];
    <span style="color: #0000ff;">for</span> (_i = 0, _len = someList.length; _i &lt; _len; _i++) {
      item = someList[_i];
      _results.push(addOne(item));
    }
    return _results;
  };
}).call(this);</pre>
]]></content:encoded>
			<wfw:commentRss>http://byatool.com/coffeescript/coffeescript-versus-javascript-example-for-fun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nemerle MVC 3 project</title>
		<link>http://byatool.com/nemerle/nemerle-mvc-3-project/</link>
		<comments>http://byatool.com/nemerle/nemerle-mvc-3-project/#comments</comments>
		<pubDate>Sun, 01 Apr 2012 15:57:35 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Nemerle]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=2522</guid>
		<description><![CDATA[You can get it from my new git hub disaster. Just out of curiosity I was trying to see if I could get a basic MVC 3 project going with Nemerle. Never heard of Nemerle? Yeah neither had I up until last week. It&#8217;s a pretty powerful .Net language that can be used to expand [...]]]></description>
			<content:encoded><![CDATA[<p>You can get it from <a href="https://github.com/byatool/BaseNemerleMvc">my new git hub disaster.</a></p>
<p>Just out of curiosity I was trying to see if I could get a basic MVC 3 project going with <a href="http://nemerle.org/About/">Nemerle</a>. Never heard of <a href="http://nemerle.org/About/">Nemerle</a>? Yeah neither had I up until last week. It&#8217;s a pretty powerful .Net language that can be used to expand the default functionality of .Net. It&#8217;s worth checking out.</p>
]]></content:encoded>
			<wfw:commentRss>http://byatool.com/nemerle/nemerle-mvc-3-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arg&#8230; Will have to actually start posting more content</title>
		<link>http://byatool.com/pointless/arg-will-have-to-actually-start-posting-more-content/</link>
		<comments>http://byatool.com/pointless/arg-will-have-to-actually-start-posting-more-content/#comments</comments>
		<pubDate>Wed, 28 Mar 2012 03:19:45 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Pointless]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=2516</guid>
		<description><![CDATA[Some interesting things to come. Totatlly not a lie and I&#8217;m totally not tipsy right now. Once I figure out this &#8220;git&#8221; thing the kids are talking about, I&#8217;ll start posting my futile attempts to turn C# into a functional language.]]></description>
			<content:encoded><![CDATA[<p>Some interesting things to come.  Totatlly not a lie and I&#8217;m totally not tipsy right now.</p>
<p>Once I figure out this &#8220;git&#8221; thing the kids are talking about, I&#8217;ll start posting my futile attempts to turn C# into a functional language.</p>
]]></content:encoded>
			<wfw:commentRss>http://byatool.com/pointless/arg-will-have-to-actually-start-posting-more-content/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fizzbuzz in Scheme/Racket</title>
		<link>http://byatool.com/pointless/fizzbuzz-in-schemeracket/</link>
		<comments>http://byatool.com/pointless/fizzbuzz-in-schemeracket/#comments</comments>
		<pubDate>Wed, 28 Mar 2012 03:17:30 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Pointless]]></category>
		<category><![CDATA[Racket]]></category>
		<category><![CDATA[Scheme]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=2502</guid>
		<description><![CDATA[No idea why I did this&#8230; (define (fizzbuzz listIn [currentList empty]) (define (showWhich itemToTell) (let ([testString (string-append (if (= (modulo itemToTell 3) 0) "Fizz" "") (if (= (modulo itemToTell 5) 0) "Buzz" ""))]) (if (= (string-length testString) 0) itemToTell testString))) (define (add-head-to-list itemList listTAddTo) (append listTAddTo (list (showWhich (first itemList) )))) (cond [(null? listIn) currentList] [...]]]></description>
			<content:encoded><![CDATA[<p>No idea why I did this&#8230;</p>
<pre>
(define (fizzbuzz listIn [currentList empty])
  (define (showWhich itemToTell)
    (let ([testString
           (string-append
            (if (= (modulo itemToTell 3) 0) "Fizz" "")
            (if (= (modulo itemToTell 5) 0) "Buzz" ""))])
      (if (= (string-length testString) 0)
          itemToTell
          testString)))
  (define (add-head-to-list itemList listTAddTo)
    (append listTAddTo (list (showWhich (first itemList) ))))
  (cond
    [(null? listIn) currentList]
    [(null? (rest listIn)) (add-head-to-list listIn currentList)]
    [else (fizzbuzz (rest listIn) (add-head-to-list listIn currentList))]))
</pre>
]]></content:encoded>
			<wfw:commentRss>http://byatool.com/pointless/fizzbuzz-in-schemeracket/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create An X  Delimited String From A Char List Using Linq Aggregate</title>
		<link>http://byatool.com/lessons/create-an-x-delimited-string-from-a-char-list-using-linq-aggregate/</link>
		<comments>http://byatool.com/lessons/create-an-x-delimited-string-from-a-char-list-using-linq-aggregate/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 19:16:56 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Lessons]]></category>
		<category><![CDATA[Aggregate]]></category>
		<category><![CDATA[Linq]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=2510</guid>
		<description><![CDATA[A quick example of how to use the Aggregate method to create a string of delimited members, or in this case characters. You might wonder why this example, or at least you should. It&#8217;s true, the character list to delimited string is pretty useless, but some idiot from where I work needed it. [TestMethod] public [...]]]></description>
			<content:encoded><![CDATA[<p>A quick example of how to use the Aggregate method to create a string of delimited members, or in this case characters. You might wonder why this example, or at least you should. It&#8217;s true, the character list to delimited string is pretty useless, but some <a href="http://byatool.com/andre/">idiot from where I work</a> needed it.</p>
<pre>[<span style="color: #008080;">TestMethod</span>]
<span style="color: #0000ff;">public void</span> GetStringFromCharacters()
{
    <span style="color: #0000ff;">var</span> charList = <span style="color: #008080;">Enumerable</span>.Range(0, 10).Select(x =&gt; 'a').ToList();

    charList
        .Aggregate(<span style="color: #800000;">""</span>, (inner, outer) =&gt; inner + outer.ToString() + <span style="color: #800000;">","</span>)
        .Should()
        .Be(<span style="color: #800000;">"a,a,a,a,a,a,a,a,a,a"</span>);
}
</pre>
<p><br/><br />
The big thing here is the &#8220;&#8221; in the Aggregate method signature.  That basically says that Inner is a string.  If I didn&#8217;t have that specified, both inner and outer would be a character.<br />
<br/><br />
YAY</p>
]]></content:encoded>
			<wfw:commentRss>http://byatool.com/lessons/create-an-x-delimited-string-from-a-char-list-using-linq-aggregate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why are things made so complicated in web design?</title>
		<link>http://byatool.com/pontification/why-are-things-made-so-complicated-in-web-design/</link>
		<comments>http://byatool.com/pontification/why-are-things-made-so-complicated-in-web-design/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 02:12:06 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Pontification]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=2465</guid>
		<description><![CDATA[Ever since Linq came out over 3? years ago (Earliest post about it that i have was from June 25 2008) I&#8217;ve been madly using it as much as I possibly could. I didn&#8217;t find it to be just some kind of syntactical sugar, or at least I learned it wasn&#8217;t eventually. Which? I don&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>Ever since Linq came out over 3? years ago (Earliest post about it that i have was from June 25 2008) I&#8217;ve been madly using it as much as I possibly could. I didn&#8217;t find it to be just some kind of syntactical sugar, or at least I learned it wasn&#8217;t eventually. Which? I don&#8217;t remember and really it doesn&#8217;t matter. Point is I&#8217;ve been a huge proponent of it and the various fun that came with. (Func, Action, anonymous types, ect) Now I had heard that it was based on functional programming but I had no real idea what that meant. It was just some kind of programming cultists and people with tin foil hats use. Let&#8217;s be honest, in the &#8220;Beer league&#8221; of programming, there was no respect for it.</p>
<p>Now flash forward a couple months ago when I went on a painful trek as I tried to find a language that could do more then what C# could handle. Far as I was concerned, I had out grown it. Like <a href="http://en.wikipedia.org/wiki/Star_Trek:_The_Motion_Picture"> VGER (And Spock for that matter)</a> I had outgrown the world of C# and needed something more even though I wasn&#8217;t sure what that something was. &#8220;It knows only that it needs, Commander. But, like so many of us&#8230; it does not know what.&#8221;</p>
<p>I thought I could find satisfaction in a new language even though <a href="http://byatool.com/pontification/i-have-found-python-and-well-im-bored/">I had failed before at that.</a> I looked into Ruby, <a href="http://www.scala-lang.org/">Scala</a>, Python (Again), <a href="http://boo.codehaus.org/">Boo</a>, but something just didn&#8217;t take. It wasn&#8217;t long before I realized that they are ultimately like C#. Sure some are dynamic, some are intelligently typed, but in the end they were the same. It was just a question of how I liked the language to look, but not how things were done. Meet the new boss, same as the old boss.</p>
<p>It was at that point I decided to just put my shoulder down and start running toward the unknown. Toward a functional language. My first stop was F# and it was surprisingly amazing. I finally found a language that would make me keep up and not the other way around. I put a ton of time into it for 3 months, but stopped. It wasn&#8217;t the language itself, the functional design, or performance. It really came down to the half &#8212;ed implementation that The good professor Microsoft decided to eh&#8230; implement. File structure (Or literally lack thereof) was painful. It&#8217;s inability to use the built in MSTest UI was even worse. To add to that, the only way I could get a nice debug enabled testing framework was through <a href="http://www.jetbrains.com/resharper/">Resharper</a> and even then I&#8217;d have to run every test in an assembly before it would add it to the suite. Add in it&#8217;s failure to work with Entity Framework without a third party library, <a href="http://fsharppowerpack.codeplex.com/">Power Pack</a> and well FFFFFFFFFUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU&#8230;</p>
<p>Ok&#8230; So I think you might get that I am a little bit mad about the situation. The reason isn&#8217;t that I&#8217;m trying to be an -ss but I REALLY LIKED F# AND THINK IT DESERVES BETTER THAN JUST TO BE SOME LAME -SS SIDE PROJECT.</p>
<p>I&#8217;ve learned this lesson before though and I just stopped bothering&#8230; at least three times until last Tuesday when I really, for really, not joking this time, quit F# for good. Yeah I&#8217;m not good at giving up on things.</p>
<p>Annoyed and looking for something to fill my need for functional languages, I decided to go all out. If I&#8217;m going to be functional (Programming functional not as in functional alcoholic) I&#8217;m doing it the full way. That&#8217;s right, I have turned to Lisp&#8230; just kidding. I am going full Haskell. Yes that language that is never talked about in name lest it release some demon or some weird looking dude when said three times in front of a mirror. That Haskell. Even before I knew what a functional language was, I had heard of it and was told to never look it in the eye and to keep on walking. I&#8217;m not sure why there is so much fear and secrecy around Haskell. I realize that, as the old cliche goes, people fear what they don&#8217;t understand, but the fear/hate people had for it seemed irrational. Like it was some kind of invading army hell bent on instilling some sort of dictatorship. I know I&#8217;m being a bit hyperbolic but the point is that people treated like it was a personal attack on programming. Like it&#8217;s existence was purely for insult and nothing else. Good thing I&#8217;m too dumb for my own good and ignored the warnings&#8230; it just took me four years to do so. (But in my defense, I hate quitting to a fault so I thought I should ride out the .Net stack.)</p>
<p>Now with this move it caused two problems: I had to take off the .Net training wheels and figure out how to even get Haskell to compile. The other was&#8230; How the &#8211;ck do I handle database oriented persistence? I mean for C# you have <a href="http://nhforge.org/Default.aspx">NHibernate</a>, <a href="http://www.llblgen.com/defaultgeneric.aspx">LLBLGEN</a>, <a href="http://subsonicproject.com/">Subsonic</a>, that entity thing&#8230; you get the point. There&#8217;s no shortage of ORMs for the .Net world. Tried to see if there was one for Haskell, but I started really thinking about this. One of the issues I had pondered with functional languages is how do you relate a database to objects if you aren&#8217;t really using an object oriented model. It&#8217;s quite a conundrum. (I spelled that right the first time.) I mean I&#8217;m sure you can force out some kind of object like model if given enough time, but was it really needed? To this I say no! (I think)</p>
<p>One of the concepts I&#8217;ve had to learn early on with functional programming is <a href="http://en.wikipedia.org/wiki/Tuple">Tuples</a>. Essentially a tuple is stuff bound together.</p>
<p>Could be a key value pair:</p>
<p><b>(&#8220;firstName&#8221;,&#8221;Sean&#8221;)</b></p>
<p>Could be a list of various strings grouped together:</p>
<p><b>[("Sean","111 Cool Lane",34),("Andre","111 Stupid Street",33)]</b></p>
<p>Point is, it&#8217;s stuff grouped in a like way. In fact, it has to be grouped in the same way. Take the one above for instance. It is a &#8220;list&#8221; of (string, string, integer). As long as anything added to it has the same signature, everything is great. If they don&#8217;t:</p>
<p><b>[("Sean", "111 Cool Lane", 34), (<strong>1</strong>, "111 Stupid Street", 33)]</b></p>
<p>Well&#8230; Kaboom. Now here&#8217;s the interesting part (One of many I hope): If you have a list of tuples and you squint real hard, you might mistake them for classes. After all, isn&#8217;t that what a class is? A bunch of stuff forced to be represented in a set way? If you think about it, this is basically how dynamic languages like Python or Javascript work. The &#8220;class&#8221; is just a bunch of key value pairs. You can call a property on an object like this:</p>
<p><b>something.DoStuff</b></p>
<p>Or you can do it like this:</p>
<p><b>something["DoStuff"]</b></p>
<p>Yes it&#8217;s psuedo code and probably not 100% correctly represented, but that&#8217;s not the point. The point is that an object can be made of from key value pairs&#8230; Basically like the tuples above&#8230; and that&#8217;s where it gets really interesting.</p>
<p>I started to think about what would it take to represent a user. Say you have a plain user with Id, FirstName, and LastName. Well you could have a class:</p>
<p><code><br />
public class User<br />
{<br />
  public int Id {get; set;}<br />
  public string FirstName {get;set;}<br />
  public string LastName {get;set;}<br />
}</code></p>
<p>Or you can have a tuple:</p>
<p><code>[(("FirstName","Sean"),("LastName","Isawesome"), ("Id", 1))]</code></p>
<p>Now here&#8217;s the funny part: I originally didn&#8217;t think the tuple representation was possible due to a possible type conflict. But sometimes in our most idiotic times there can emerge a real idea. The idea is simple:</p>
<blockquote><p>WHY THE &#8211;CK DO WE SPEND SO MUCH TIME FORCING TYPES IF MOST OF THE TIME WE JUST NEED STRINGS!?!!</p></blockquote>
<p>I know, it sounds odd at first but if you really think about it, does it matter if an Id is an integer? Sure in the database, but outside of it? Here&#8217;s a typical MVC round trip:</p>
<pre><a href="http://byatool.com/wp-content/uploads/TypicalMVCPath.png"><img class="alignnone size-full wp-image-2472" title="TypicalMVCPath" src="http://byatool.com/wp-content/uploads/TypicalMVCPath.png" alt="" width="1031" height="330" /></a></pre>
<p>You take in a json string and turn part of it into an integer. You push that integer to a class (Model or other wise) and then use the class to transport that Id to be used as a string in a sql query or it gets converted to some other database happy type. It then is pulled back out of that database friendly type and pushed into an integer so it can hydrate a user class. Then the id is passed into a model so it can be turned into a string for html or json.</p>
<p>This begs the question:</p>
<blockquote><p>WHY THE &#8211;CK DO WE SPEND SO MUCH TIME FORCING TYPES IF MOST OF THE TIME WE JUST NEED STRINGS!?!!</p></blockquote>
<p>Think about and I mean really think about it. How often do things typed as integers (Or decimal or date or whatever the &#8211;ck you want) get used for anything but to be aimlessly typed and retyped? How often do any numbers get used for anything number related? In the world o&#8217; web development there is very little use for numbers. Sure you might have to sum them up, but doesn&#8217;t it seem more logically to start as a string and only type when it&#8217;s needed as opposed to type something to anything but a string when all it ever will be used as is a string? It makes no &#8211;cking sense. None.</p>
<p><i>But maybe somewhere you might have to validate that the number falls within a certain range&#8230;</i> GREAT! Convert to an integer and check!.</p>
<p><i>But maybe it has to be a proper date.</i> &#8211;CKING GREAT CONVERT AND CHECK!</p>
<p><i>But, but what about when persisting to a database&#8230;</i> THIS IS A GOOD REASON&#8230; eh to convert.</p>
<p>If there&#8217;s anything I&#8217;ve learned from the newfangled ideas of lean and such; it&#8217;s that you build only what you need. Don&#8217;t over complicate. Don&#8217;t over think. Don&#8217;t pass go and collect 200$. If there is no reason to type something as an integer, then why would you? Join the revolution. We can win this one or look like complete &#8211;sses while trying.  I can&#8217;t promise which, but I can promise one will happen.</p>
<p>This is just the begining&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://byatool.com/pontification/why-are-things-made-so-complicated-in-web-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fluent Nhibernate, Linq to NHibernate, MS Test, Fluent Assertions, and a working example</title>
		<link>http://byatool.com/nhibernate/fluent-nhibernate-linq-to-nhibernate-ms-test-fluent-assertions-and-you/</link>
		<comments>http://byatool.com/nhibernate/fluent-nhibernate-linq-to-nhibernate-ms-test-fluent-assertions-and-you/#comments</comments>
		<pubDate>Mon, 19 Dec 2011 01:53:36 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[NHibernate]]></category>
		<category><![CDATA[Fluent Assertions]]></category>
		<category><![CDATA[Fluent NHibernate]]></category>
		<category><![CDATA[MS Test]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=2457</guid>
		<description><![CDATA[So out of pure curiosity I decided to go down the NHibernate path and it had nothing to do with the headache that is Entity Framework&#8230; nothing at all. First I wanted to see where Linq to NHibernate was at after hearing about it years ago. Turns out it&#8217;s doing pretty well&#8230; and actually works [...]]]></description>
			<content:encoded><![CDATA[<p>So out of pure curiosity I decided to go down the NHibernate path and it had nothing to do with the headache that is Entity Framework&#8230; nothing at all.</p>
<p>First I wanted to see where Linq to NHibernate was at after hearing about it years ago.  Turns out it&#8217;s doing pretty well&#8230; and actually works <a href="http://www.d80.co.uk/post/2011/02/20/Linq-to-NHibernate-Tutorial.aspx">thanks to this link.</a>  So with that in mind, I also wanted to check out <a href="http://fluentnhibernate.org/">Fluent NHibernate</a> since I had somehow knew it was a project created with the hope to remove the config files NHibernate used.  (No idea how I knew that, must have known someone who used it.)  Well just so I could be completely wild, I just decided to try out <a href="http://fluentassertions.codeplex.com/">Fluent Assertions</a> which is a library used to help MS Test assertions to be readable.  Crazy idea I know.</p>
<p>Well after a bit of reading and a couple hours of work, I came up with a working example of them all in one project.  Go me.</p>
<p><a href="http://demo.byatool.com/NhibernateTest.zip">Here it is.</a></p>
<p>Only thing you need to do is have a database handy and open up the &#8220;~\NhibernateTest\NhibernateTest\NHibernateHelper.cs&#8221; file and set the Username, Password, Catalogue, and Server name.  Then just create a database (But not the tables) that corresponds to the values you entered.  Now the nice thing is that the first time you run any of the tests, it (Being Fluent NHibernate) will create that tables and columns needed.  This is something that works a lot like Active Records for Ruby.  This behavior is controlled by:</p>
<pre>
.ExposeConfiguration(cfg => new SchemaExport(cfg).Create(true, true))
</pre>
<p>The second True is the important one.  If you keep that True, it will drop and recreate the tables every time you run a test.  Change it to False and it will stop doing that.  </p>
<p>Just keep in mind I&#8217;m not presenting any Best Practices here.  This is an example but not exactly production ready.</p>
]]></content:encoded>
			<wfw:commentRss>http://byatool.com/nhibernate/fluent-nhibernate-linq-to-nhibernate-ms-test-fluent-assertions-and-you/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>F#: How F# doesn&#8217;t require specifying parameter types in the method signature.</title>
		<link>http://byatool.com/f/f-how-f-doesnt-require-specifying-a-parameter-types-in-the-method-signature/</link>
		<comments>http://byatool.com/f/f-how-f-doesnt-require-specifying-a-parameter-types-in-the-method-signature/#comments</comments>
		<pubDate>Sun, 04 Dec 2011 20:10:12 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[Type Casting]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=2433</guid>
		<description><![CDATA[Found this one by mistake when I was trying to figure out how to declare optional parameters in F#. So a typical method signature would be something like this: member public x.CreateUserPost(userName:String, password:String) = 1 = 1 Now let&#8217;s say you have a type named LoginModel that takes in two strings in it&#8217;s constructor: type [...]]]></description>
			<content:encoded><![CDATA[<p>Found this one by mistake when I was trying to figure out how to declare optional parameters in F#. So a typical method signature would be something like this:</p>
<pre> <span style="color: #0000ff;">member public</span> x.CreateUserPost(userName:<span style="color: #008080;">String</span>, password:<span style="color: #008080;">String</span>) =
   1 = 1</pre>
<p>Now let&#8217;s say you have a type named LoginModel that takes in two strings in it&#8217;s constructor:</p>
<pre><span style="color: #0000ff;">type</span> <span style="color: #008080;">LoginModel</span>(userName:<span style="color: #008080;">String</span>, password:<span style="color: #008080;">String</span>) =
  ...</pre>
<p>And the it&#8217;s added to the method:</p>
<pre><span style="color: #0000ff;">member public</span> x.CreateUserPost(userName:<span style="color: #008080;">String</span>, password:<span style="color: #008080;">String</span>) =
  <span style="color: #0000ff;">new</span> <span style="color: #008080;">LoginModel</span>(userName, password)</pre>
<p>As you can see, LoginModel has its two parameters explicitly typed and because of this they don&#8217;t have to be explicitly typed in the method signature. With that in mind you can reduce the method signature to this:</p>
<pre><span style="color: #0000ff;">member public</span> x.CreateUserPost(userName, password) =
  <span style="color: #0000ff;">new</span> <span style="color: #008080;">LoginModel</span>(userName, password)</pre>
<p>And that&#8217;s completely &#8220;legal&#8221; unlike the complete series of My Little Pony you have on your computer. Shameful.</p>
]]></content:encoded>
			<wfw:commentRss>http://byatool.com/f/f-how-f-doesnt-require-specifying-a-parameter-types-in-the-method-signature/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>F#: Use reflection to call a private or protected method</title>
		<link>http://byatool.com/f/f-use-reflection-to-call-a-private-or-protected-method/</link>
		<comments>http://byatool.com/f/f-use-reflection-to-call-a-private-or-protected-method/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 15:44:24 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[Reflection]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=2377</guid>
		<description><![CDATA[This isn&#8217;t anything ground breaking so if you are expecting it to be, tough luck. The world doesn&#8217;t revolve around you. It revolves around me. Making the switch to F# has caused me to redo a lot of older framework stuff and using reflection to call methods is part of that stuff. I could sit [...]]]></description>
			<content:encoded><![CDATA[<p>This isn&#8217;t anything ground breaking so if you are expecting it to be, tough luck. The world doesn&#8217;t revolve around you. It revolves around me.</p>
<p>Making the switch to F# has caused me to redo a lot of older framework stuff and using reflection to call methods is part of that stuff. I could sit here and go on about something and waste your time, but I&#8217;ll be nice this time.</p>
<pre><span style="color: #0000ff;">open</span> System
<span style="color: #0000ff;">open</span> System.Reflection
<span style="color: #0000ff;"> module</span> ReflectionUtility =
  <span style="color: #808000;">//This is used to make sure the GetMethod method doesn't skip private or protected</span>
  <span style="color: #0000ff;">let</span> <span style="color: #0000ff;">public</span> BindingFlagsToSeeAll =
    <span style="color: #008080;">BindingFlags</span>.Static |||
    <span style="color: #008080;">BindingFlags</span>.FlattenHierarchy |||
    <span style="color: #008080;">BindingFlags</span>.Instance |||
    <span style="color: #008080;">BindingFlags</span>.NonPublic |||
    <span style="color: #008080;">BindingFlags</span>.Public;

  <span style="color: #0000ff;">type</span> <span style="color: #008080;">MethodReflection</span> <span style="color: #0000ff;">public</span>() =
    <span style="color: #808000;">//Get the method by the method name from the class type</span>
    <span style="color: #0000ff;">member</span> <span style="color: #0000ff;">private</span> x.FindMethodInfo&lt;'targetClass&gt;(methodName:<span style="color: #008080;">String</span>, source:'targetClass) =
      (source.GetType()).GetMethod(methodName, BindingFlagsToSeeAll)

    <span style="color: #808000;">//Call the find method and run the found method</span>
    <span style="color: #0000ff;">member</span> <span style="color: #0000ff;">public</span> x.ExecuteMethod&lt;'returnType, 'target&gt;(source:'target, methodName:<span style="color: #008080;">String</span>, argTypes:<span style="color: #008080;">Type</span>[], args:<span style="color: #008080;">Object</span>[]) =
      <span style="color: #0000ff;">let</span> info = x.FindMethodInfo(methodName, source)
      info.Invoke(source, args) <img src='http://byatool.com/wp-includes/images/smilies/icon_confused.gif' alt=':?' class='wp-smiley' /> &gt; 'returnType</pre>
<p>As you can see, this is extremely easy and short to use. I would suggest adding in some sort of caching if you are using this for anything that needs performance as I&#8217;m pretty sure reflection is still somewhat expensive. Most likely if I were caching anything it would be the method info.</p>
<p>If you&#8217;re new to F#, or due to an unfortunate turn of events ended up here, you might be wondering what all that &#8216;word stuff is or how the hell FindMethodInfo is returned</p>
<p>Well the &#8216; notation is simply the way F# defines generic types.  It may look odd compared to C# but one nice thing is you never have to worry that your generic constraint might mirror the name of a variable/parameter/field.</p>
<p>The FindMethodInfo does have a return.  F# assumes that the last line in the method is the return.  This is really nice feature that saves a little bit of time by not having to type Return.  The other nice thing about it is that F# will infer the method&#8217;s return type by the last line so you never have to type out the return type for a method:</p>
<pre>C#:

  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span> ReturnString()
  {
    <span style="color: #0000ff;">return</span> <span style="color: #800000;">""</span>;
  }

F#
  <span style="color: #0000ff;">member</span> <span style="color: #0000ff;">public</span> x.ReturnString() =
    <span style="color: #800000;">""</span></pre>
<p>And that&#8217;s one reason why all the cool kids use F#.</p>
]]></content:encoded>
			<wfw:commentRss>http://byatool.com/f/f-use-reflection-to-call-a-private-or-protected-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>F#: Creating your own mocks using Object Expressions&#8230; Wow</title>
		<link>http://byatool.com/f/f-creating-your-own-mocks-using-object-expressions-wow/</link>
		<comments>http://byatool.com/f/f-creating-your-own-mocks-using-object-expressions-wow/#comments</comments>
		<pubDate>Sun, 13 Nov 2011 15:57:22 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[Dynamic]]></category>
		<category><![CDATA[Expression]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=2365</guid>
		<description><![CDATA[This just in from the &#8220;Wow, I can&#8217;t believe how easy this is&#8221; update desk: You can roll your own mocks &#8220;dynamically&#8221;, even when mocking an interface. No, this isn&#8217;t too good to be true. No that weird tingling isn&#8217;t from your bullsh@# meter going off. (But you really should get that tingling checked by [...]]]></description>
			<content:encoded><![CDATA[<p>This just in from the &#8220;Wow, I can&#8217;t believe how easy this is&#8221; update desk:</p>
<p>You can roll your own mocks &#8220;dynamically&#8221;, even when mocking an interface. No, this isn&#8217;t too good to be true. No that weird tingling isn&#8217;t from your bullsh@# meter going off. (But you really should get that tingling checked by a doctor) This is F#. And this isn&#8217;t SPARTA!!! AHRHARHARHRAhRHARHR SO FUNAY!11</p>
<p>Say you have a test method that wants to call a method Validate on the Validator : IValidator class. Here is the IValidator class:</p>
<pre>  <span style="color: #0000ff;">type</span> <span style="color: #008080;">IValidator</span>&lt;'a, 'b&gt; =
    <span style="color: #0000ff;">abstract</span> AddValidationMethod : ('a -&gt; <span style="color: #008080;">MethodResult</span>&lt;'b&gt;) -&gt; <span style="color: #008080;">IValidator</span>&lt;'a, 'b&gt;</pre>
<p><em>(Side note: the &#8216;a and &#8216;b are just F#&#8217;s generic notation. Generic members are preceeded by a &#8216;)</em></p>
<p>Somewhere in your code this IValidator is called by someone, say a controller action:</p>
<pre>  <span style="color: #0000ff;">member</span> <span style="color: #0000ff;">public</span> x.LoginPost(userName:<span style="color: #008080;">String</span>, password:<span style="color: #008080;">String</span>) =
    <span style="color: #0000ff;">let</span> loginModel = <span style="color: #0000ff;">new</span> <span style="color: #008080;">LoginModel</span>(userName, password)
    <span style="color: #0000ff;">let</span> result = x.ControllerValidator.Validate(loginModel)</pre>
<p>And of course you would have a controller definition look like this:</p>
<pre>  <span style="color: #0000ff;">type</span> <span style="color: #008080;">MainController</span>(validator:IValidator&lt;<span style="color: #008080;">LoginModel</span>, <span style="color: #008080;">LoginModel</span>&gt;) =
    <span style="color: #0000ff;">inherit</span> Controller()
      <span style="color: #0000ff;">member</span> <span style="color: #0000ff;">private</span> x.ControllerValidator <span style="color: #0000ff;">with</span> <span style="color: #0000ff;">get</span>() = validator</pre>
<p>So you are set up for mocking.</p>
<p>There are three way, but if you&#8217;re already bored (And I assume you are) then just go to 3.</p>
<p><strong>1) Mock the IValidator</strong></p>
<p>As you can imagine, this could be obnoxious to mock up as the AddValidationMethod is adding a method that takes in &#8216;a and a MethodResult&lt;&#8217;a&gt; and then returns an IValidator&lt;&#8217;a, &#8216;b&gt;. Can it be done? I would asssume so, but there is another way.</p>
<p><strong>2) Create a new class (Class file) that implements IValidator.</strong></p>
<p>This is the most simple way of doing it. You just make a class that implements IValidator and just pass back what you want. Problem is: This isn&#8217;t very reusable as it is now a static class.</p>
<p><strong>3) Create a class on the fly.</strong></p>
<p>And this is the good stuff. F# allows the creation of a class (That implements an interface) &#8220;inline&#8221;&#8230; not sure what word I&#8217;m looking for so just go with it.</p>
<pre>  <span style="color: #0000ff;">let</span> validatorWithFalseReturn =
    {
      <span style="color: #0000ff;">new</span> <span style="color: #008080;">IValidator</span>&lt;'a, 'b&gt; <span style="color: #0000ff;">with</span>
        <span style="color: #0000ff;">member</span> x.AddValidationMethod(methodToAdd:('a -&gt; MethodResult&lt;'b&gt;)) =
          <span style="color: #0000ff;">new</span> <span style="color: #008080;">Validator</span>&lt;'a, 'b&gt;() :&gt; <span style="color: #008080;">IValidator</span>&lt;'a, 'b&gt;

        <span style="color: #0000ff;">member</span> x.Validate(model:'a) =
          (<span style="color: #0000ff;">new</span> <span style="color: #008080;">MethodResult</span>&lt;'b&gt;()).AddErrorMessage(<span style="color: #800000;">""</span>)
    }

    <span style="color: #0000ff;">let</span> mainController = <span style="color: #0000ff;">new</span> MainController(validatorWithFalseReturn)</pre>
<p>(Side note: you might see the :&gt; notation. This is basically the same as (SomeInterface)SomeClass in C#.)</p>
<p>As you can see, I created a new type and set it into the instantiated controller. As you can imagine, you could create a method that takes in a method to set AddValidation to. This has some really great potential like rolling your own mocking system.</p>
<p>So <a href="http://byatool.com/f/f-duck-typing-with-generic-constraints-and-why-you-will-be-speechless">once again</a> F# <a href="http://byatool.com/f/f-and-using-strings-for-method-and-classtype-names/">is looking</a> to be an amazing language.</p>
]]></content:encoded>
			<wfw:commentRss>http://byatool.com/f/f-creating-your-own-mocks-using-object-expressions-wow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>F#: Duck typing with generic constraints and why you will be speechless</title>
		<link>http://byatool.com/f/f-duck-typing-with-generic-constraints-and-why-you-will-be-speechless/</link>
		<comments>http://byatool.com/f/f-duck-typing-with-generic-constraints-and-why-you-will-be-speechless/#comments</comments>
		<pubDate>Fri, 11 Nov 2011 17:01:01 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[Dynamic]]></category>
		<category><![CDATA[Generics]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=2359</guid>
		<description><![CDATA[So I&#8217;ve been working on a validation design that basically allows validation methods to be added to a list and then run. A small part of it: member x.Validate(valueToCheck:'a) = methodList &#124;&#62; Seq.map (fun (methodToRun) -&#62; methodToRun(valueToCheck)) &#124;&#62; Seq.reduce (fun(outer) inner -&#62; outer.MergeResults(inner)) What this is saying is take a list of methods, run them [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;ve been working on a validation design that basically allows validation methods to be added to a list and then run. A small part of it:</p>
<pre>    <span style="color: #0000ff;">member</span> x.Validate(valueToCheck:'a) =
      methodList
      |&gt; <span style="color: #339966;">Seq</span>.map (<span style="color: #0000ff;">fun</span> (methodToRun) -&gt; methodToRun(valueToCheck))
      |&gt; <span style="color: #339966;">Seq</span>.reduce (<span style="color: #0000ff;">fun</span>(outer) inner -&gt; outer.MergeResults(inner))</pre>
<p>What this is saying is take a list of methods, run them and make a list of their results, then merge the results into one. While I won&#8217;t get into what the results are (And I almost typed that as resluts which makes me think there is a refurbishing factory for sluts.) just know that each result can merge with another and combine values.</p>
<p>The biggest problem I was running into was a way to allow any method to be added and let the method decide what it needs to run correctly. In C# this can be done easily with dynamic:</p>
<pre>  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> MethodResult ValidatePasswordExistence(dynamic modelToCheck)
  {
    <span style="color: #0000ff;">var</span> returnResult = <span style="color: #0000ff;">new</span> <span style="color: #339966;">MethodResult</span>();
    <span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">string</span>.IsNullOrEmpty(modelToCheck.Password))
    {
      returnResult = returnResult.AddErrorMessage(<span style="color: #339966;">UserError</span>.PasswordIsNullOrEmpty);
    }

    <span style="color: #0000ff;">return</span> returnResult;
  }</pre>
<p>The use of a dynamic parameter means that all validation methods can have the same signature which makes it really easy to send the same class into any method in the list. The problem with F# is there is no ready way to use dynamic and I&#8217;m not sure it should be. F# is heavily based on typing and dynamic kind of goes in the opposite direction. So I thought my ship was sunk, that is if I had a ship to sink and said ship hand&#8217;t sunk already.</p>
<p>Thanks to some help from <a href="http://stackoverflow.com/questions/8095512/f-member-constraints-to-help-create-seemingly-dynamic-types">the O</a>, i was able to get past this not only without dynamic, but a way to strongly type any object coming into the method:</p>
<pre>  <span style="color: #0000ff;">let</span> <span style="color: #0000ff;">inline</span> UserNameExists (userModel) =
    <span style="color: #0000ff;">let</span> userName = (^a : (<span style="color: #0000ff;">member</span> UserName : <span style="color: #0000ff;">String</span> <span style="color: #0000ff;">with</span> <span style="color: #0000ff;">get</span>) (userModel))

    <span style="color: #0000ff;">let</span> result =
      <span style="color: #0000ff;">match</span> userName <span style="color: #0000ff;">with</span>
        | <span style="color: #0000ff;">null</span> -&gt; (<span style="color: #0000ff;">new</span> MethodResult()).AddErrorMessage(UserErrors.UserNameIsNullOrEmpty)
        | "" -&gt; (<span style="color: #0000ff;">new</span> MethodResult()).AddErrorMessage(UserErrors.UserNameIsNullOrEmpty)
        | _ -&gt; <span style="color: #0000ff;">new</span> MethodResult()

    result</pre>
<p>The important part is the second line. This line basically says that anything coming into the method as userModel has to have a property of UserName. One of the dangerous issues with dynamic is there are no compile time checks to make sure that any object going in will have the property or method you need it to. This isn&#8217;t true of F#. You not only get to pass in any object you want (That has what is required by the check) but you get complile time errros if you try to pass in an object that doesn&#8217;t fit the requirements.</p>
<p>Yup, that&#8217;s right. You&#8217;re speechless.</p>
]]></content:encoded>
			<wfw:commentRss>http://byatool.com/f/f-duck-typing-with-generic-constraints-and-why-you-will-be-speechless/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Culture shock of scaling back from full-time work&#8230;</title>
		<link>http://byatool.com/uncategorized/culture-shock-of-scaling-back-from-full-time-work/</link>
		<comments>http://byatool.com/uncategorized/culture-shock-of-scaling-back-from-full-time-work/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 18:22:24 +0000</pubDate>
		<dc:creator>Amy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[IT Life]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=2355</guid>
		<description><![CDATA[As a blessing, my husband recently got promoted to full-time status at his job.  This meant that I was able to leave my full-time job that was interesting, but demanding and stressful.  After a few weeks of re-calibrating and getting a lot of home projects finished, I found that I really missed writing and coding.  [...]]]></description>
			<content:encoded><![CDATA[<p>As a blessing, my husband recently got promoted to full-time status at his job.  This meant that I was able to leave my full-time job that was interesting, but demanding and stressful.  After a few weeks of re-calibrating and getting a lot of home projects finished, I found that I really missed writing and coding.  I wrote a few simple things to get warmed up, but I&#8217;m really glad that I did because it&#8217;s breathtaking how quickly those skills will slip if you don&#8217;t use them often.</p>
<p>I, like many young (okay, youngish) moms with kids in school, would like to find something useful and if possible profitable to do in the 6 or so hours a day while the kids are away.  I&#8217;m finding that getting part-time or freelance work isn&#8217;t as easy as I thought.  The consensus that I&#8217;ve read has been that for the most part, you&#8217;re going to have to tap all your network of peers/friends/family to get leads then start out working for little to no pay in order to build a reputation.  I pretty much suspected this, but what I didn&#8217;t fully realize is something my sister brought up:</p>
<p>&#8220;Contracting/consulting can be awful in usually two ways: 1) What is available is the bottom of the barrel, makes no sense, and nobody else will work on it.  2) The project is interesting, but it has become a steaming pile of spaghetti code and they want you to wave your magic mouse and have it all fixed two weeks ago for next to nothing.&#8221;</p>
<p>So&#8230; here&#8217;s my dilemma.  I want to be able to work part-time or telecommute so that I can keep my 10+ years of experience and skills sharp, but I would like to eventually get paid.</p>
<p>What I can&#8217;t understand is why more companies don&#8217;t allow their IT employees to have more flexibility provided that they well document the work they do and get it in on time.  Especially because office space is a premium and gas prices are through the roof right now.  In Pittsburgh, we have spectacularly bad traffic and highway infrastructure.  If business owners know how expensive it is for employees to commute/park/bus downtown, why don&#8217;t they give them the option to take a small pay cut and telecommute?  Both sides win that way.</p>
<p>Anyway, in the meantime while I&#8217;m fishing for contract leads, I&#8217;d like to start developing some small bite-sized projects.  jQuery and Javascript are good and familiar to me so far, but do the readers have any suggestions?</p>
]]></content:encoded>
			<wfw:commentRss>http://byatool.com/uncategorized/culture-shock-of-scaling-back-from-full-time-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>F# and using strings for method and class/type names</title>
		<link>http://byatool.com/f/f-and-using-strings-for-method-and-classtype-names/</link>
		<comments>http://byatool.com/f/f-and-using-strings-for-method-and-classtype-names/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 21:43:44 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[FSUnit]]></category>
		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=2335</guid>
		<description><![CDATA[So after about 2 months of jumping back and forth between languages (Including and not only: Ruby, Python, IronPython, Boo, Scala, and a lot more I don&#8217;t remember) I&#8217;ve finally settled on F# for more reasons than I will put in this post. BUT one thing that kind of blew me away, and I realize [...]]]></description>
			<content:encoded><![CDATA[<p>So after about 2 months of jumping back and forth between languages (Including and not only: <a href="http://www.ruby-lang.org/en/">Ruby</a>, <a href="http://www.python.org/">Python</a>, <a href="http://ironpython.codeplex.com/">IronPython</a>, <a href="http://boo.codehaus.org/">Boo</a>, <a href="http://www.scala-lang.org/">Scala</a>, and a lot more I don&#8217;t remember) I&#8217;ve finally settled on F# for more reasons than I will put in this post. BUT one thing that kind of blew me away, and I realize that doesn&#8217;t take much (I thought the ending to Terminator 3 was great), was the ability to name methods with string representations&#8230; eh wha?</p>
<p>Well I was writing unit tests and stumbled onto the <a href="http://fsunit.codeplex.com/">FSUnit &#8220;library&#8221;</a> (and by &#8220;library&#8221; I mean a single file). Well on the page there was an example that looked a sumthin&#8217; like this:</p>
<pre>[&lt;<span style="color: #339966;">TestFixture</span>&gt;]
<span style="color: #0000ff;">type</span> <span style="color: #ff0000;">``Given a LightBulb that has had its state set to true``</span> ()=
  ...</pre>
<p>Now if you haven&#8217;t used F# just replace &#8220;type&#8221; with &#8220;class&#8221;. Essential there is a string/text built name. Not something you see, or at least I haven&#8217;t, in any old language. So I went forth and was fruitful and multipled&#8230; with unit tests&#8230; gross.</p>
<pre>[&lt;<span style="color: #339966;">TestFixture</span>&gt;]
<span style="color: #0000ff;">type public</span> <span style="color: #ff0000;">``When Adding``</span>() =
    <span style="color: #0000ff;">let</span> returnThing = <span style="color: #0000ff;">new</span> MethodResult() :&gt; IResult
    <span style="color: #0000ff;">let</span> randomTool = <span style="color: #0000ff;">new</span> RandomTool()

    [&lt;<span style="color: #339966;">Test</span>&gt;]
    <span style="color: #0000ff;">member public</span> x.<span style="color: #ff0000;">``A Warning Message The Success Flag Is Set To True``</span>() =
        returnThing.AddMessage(new MessageItem(randomTool.RandomString(10), MessageCategory.Warning)).Success |&gt; should be True</pre>
<p>And using Resharper&#8217;s unit test box thingy it gave a read out of:</p>
<pre>  <span style="color: #0000ff;">When Adding A Warning Message </span>
     <span style="color: #000080;">The Success Flag Is Set To True</span>             <span style="color: #008000;">Success</span></pre>
<p>Now I&#8217;m not sure how useful this is for non unit testing but I think it&#8217;s obvious it is to reading Unit Test results. Pretty nice.</p>
]]></content:encoded>
			<wfw:commentRss>http://byatool.com/f/f-and-using-strings-for-method-and-classtype-names/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XUnit and Connection Strings</title>
		<link>http://byatool.com/lessons/xunit-and-connection-strings/</link>
		<comments>http://byatool.com/lessons/xunit-and-connection-strings/#comments</comments>
		<pubDate>Sat, 15 Oct 2011 16:41:23 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Lessons]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[Xunit]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=2312</guid>
		<description><![CDATA[A real quick one but maybe a good one. I was running the xUnit.gui.exe program to run units tests using xUnit&#8230; duh. Problem I ran into is that xUnit is not a part of the solution that the tests were. This caused issues when trying to run integration tests since the needed app.config wouldn&#8217;t be [...]]]></description>
			<content:encoded><![CDATA[<p>A real quick one but maybe a good one.  </p>
<p>I was running the <a href="http://xunit.codeplex.com/">xUnit.gui.exe</a> program to run units tests using xUnit&#8230; duh.  Problem I ran into is that xUnit is not a part of the solution that the tests were.  This caused issues when trying to run integration tests since the needed app.config wouldn&#8217;t be read by xUnit as the config file used when running an app is the config file from the topmost (Usually UI) project/application.  So I made a wild guess that if I follow that logic, what little there may be, and add the connection strings to the <a href="http://byatool.com/test/xunit-gui-exe-this-assembly-is-built-by-a-runtime-newer-than-the-currently/">xunit.gui.exe.config</a> file as if it were an app.config/web.config, it should use the connection strings added&#8230; and turns out it did.</p>
<p><a href="http://byatool.com/wp-content/uploads/XunitConnections.png"><img src="http://byatool.com/wp-content/uploads/XunitConnections.png" alt="" title="XunitConnections" width="742" height="452" class="alignleft size-full wp-image-2313" /></a></p>
<p>And there you have it&#8230; it being the solution and not a clown.</p>
]]></content:encoded>
			<wfw:commentRss>http://byatool.com/lessons/xunit-and-connection-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun with F# and Method Reduction</title>
		<link>http://byatool.com/lessons/fun-with-f-and-method-reduction/</link>
		<comments>http://byatool.com/lessons/fun-with-f-and-method-reduction/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 18:47:44 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Lessons]]></category>
		<category><![CDATA[F#]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=2306</guid>
		<description><![CDATA[So the first and second methods came from this book , but I thought for fun I might reduce it further to see how small a call could get. Basically take a number and divide it by another number 3 times. let bytesToGb item = let itemB = item / 1024I let itemC = itemB [...]]]></description>
			<content:encoded><![CDATA[<p>So the first and second methods came from <a href="http://www.amazon.com/Programming-comprehensive-writing-complex-problems/dp/0596153643"> this book </a>, but I thought for fun I might reduce it further to see<br />
how small a call could get.</p>
<p>Basically take a number and divide it by another number 3 times.</p>
<p><span style="color: #0000ff;">let</span> bytesToGb item =<br />
<span style="color: #0000ff;">let</span> itemB = item / 1024I<br />
<span style="color: #0000ff;">let</span> itemC = itemB / 1024I<br />
<span style="color: #0000ff;">let</span> itemD = itemC / 1024I</p>
<p><strong>Is the same as</strong>:<br />
<span style="color: #0000ff;">let</span> bytesToGb item =<br />
<span style="color: #0000ff;">let</span> x = x / 1024I<br />
<span style="color: #0000ff;">let</span> x = x / 1024I<br />
<span style="color: #0000ff;">let</span> x = x / 1024I</p>
<p><strong>And more reduction:</strong><br />
<span style="color: #0000ff;">let</span> bytesToGb item =<br />
item<br />
|&gt; (fun x -&gt; x/1024L)<br />
|&gt; (fun x -&gt; x/1024L)<br />
|&gt; (fun x -&gt; x/1024L)</p>
<p><strong>Or more:</strong><br />
<span style="color: #0000ff;"> let</span> divide x = x/1024L<br />
<span style="color: #0000ff;">let</span> bytesToGb = divide &gt;&gt; divide &gt;&gt; divide</p>
<p>If you&#8217;re familiar with Func/Action, Linq, ect this might actually look a lot like some of the newer &#8220;functional like&#8221; additions to C#. Well at least the third one. Funny part, and I didn&#8217;t know this, is that most of the more interesting additions to C# (Generics, Linq, Lambda expressions) actually came from F#; Which was built to match other existing functional languages like Haskel)  Go figure.</p>
]]></content:encoded>
			<wfw:commentRss>http://byatool.com/lessons/fun-with-f-and-method-reduction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

