<?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>Mind Gravy &#187; General</title>
	<atom:link href="http://www.mindgravy.net/category/general/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mindgravy.net</link>
	<description>Slather Your Mind</description>
	<lastBuildDate>Thu, 10 Jun 2010 04:27:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Writing from my iPad</title>
		<link>http://www.mindgravy.net/2010/05/26/writing-from-my-ipad/</link>
		<comments>http://www.mindgravy.net/2010/05/26/writing-from-my-ipad/#comments</comments>
		<pubDate>Wed, 26 May 2010 21:41:57 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[iPad]]></category>

		<guid isPermaLink="false">http://www.mindgravy.net/2010/05/26/writing-from-my-ipad/</guid>
		<description><![CDATA[This is my first post written directly on my iPad. This device has made our lives more interesting and has a lot uses for children. I&#8217;ve enjoyed the initial experience with the iPad and I think the rest of my family has as well. I would say the games and coloring style apps have been [...]]]></description>
			<content:encoded><![CDATA[<p>This is my first post written directly on my iPad.  This device has made our lives more interesting and has a lot uses for children.  I&#8217;ve enjoyed the initial experience with the iPad and I think the rest of my family has as well.  I would say the games and coloring style apps have been the most enjoyable, along with the ability to stream movies and videos.</p>
<p>The apps that I have installed on here are:</p>
<ul>
<li><strong>Air Video</strong> &#8211; stream video from a server directly to the iPad</li>
<li><strong>Netflix</strong> &#8211; mandatory for video</li>
<li><strong>Plants vs. Zombies</strong> &#8211; my wife truly enjoys this game, much to my amusement</li>
<li><strong>Flight Control HD</strong> &#8211; I have a thing for planes</li>
<li><strong>RadarScope</strong> &#8211; Level 2 radar at your fingertips, along with Spotter Network integration make for an awesome experience</li>
<li><strong>X-Plane</strong> &#8211; again, an excellent flight simulator</li>
</ul>
<p>The one thing I am surprised with is reading books.  I thought that it would be different because of the backlit screen and my eyes would hurt, but I haven&#8217;t had any problems picking up the iPad to read a nice book on Python.</p>
<p>Overall, I am extremely happy we purchased the iPad.</p>
<hr />
<p><strong>UPDATE:</strong> I forgot to mention <strong>GoodReader</strong> which is an awesome app to manage documents.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mindgravy.net/2010/05/26/writing-from-my-ipad/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>I&#8217;ve embarked on a new career</title>
		<link>http://www.mindgravy.net/2010/04/01/ive-embarked-on-a-new-career/</link>
		<comments>http://www.mindgravy.net/2010/04/01/ive-embarked-on-a-new-career/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 14:19:59 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.mindgravy.net/2010/04/01/ive-embarked-on-a-new-career/</guid>
		<description><![CDATA[I have decided that programming is no longer a viable career, so I have decided to being mentoring under Eduard Khil:]]></description>
			<content:encoded><![CDATA[<p>I have decided that programming is no longer a viable career, so I have decided to being mentoring under Eduard Khil:</p>
<p> <object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/pYU7oG2V7uc&amp;hl=en_US&amp;fs=1&amp;color1=0x2b405b&amp;color2=0x6b8ab6"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/pYU7oG2V7uc&amp;hl=en_US&amp;fs=1&amp;color1=0x2b405b&amp;color2=0x6b8ab6" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mindgravy.net/2010/04/01/ive-embarked-on-a-new-career/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Merry Christmas</title>
		<link>http://www.mindgravy.net/2009/12/25/merry-christmas/</link>
		<comments>http://www.mindgravy.net/2009/12/25/merry-christmas/#comments</comments>
		<pubDate>Fri, 25 Dec 2009 05:37:49 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[christmas]]></category>

		<guid isPermaLink="false">http://www.mindgravy.net/2009/12/25/merry-christmas/</guid>
		<description><![CDATA[I want to wish everyone a Merry Christmas and a prosperous New Year.]]></description>
			<content:encoded><![CDATA[<p>I want to wish everyone a Merry Christmas and a prosperous New Year.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Merry Christmas" border="0" alt="Merry Christmas" src="http://www.mindgravy.net/wp-content/uploads/2009/12/1110073_17370751.png" width="404" height="537" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mindgravy.net/2009/12/25/merry-christmas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.NET + StructureMap = Epic Win</title>
		<link>http://www.mindgravy.net/2009/11/26/asp-net-structuremap-epic-win/</link>
		<comments>http://www.mindgravy.net/2009/11/26/asp-net-structuremap-epic-win/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 05:17:49 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.mindgravy.net/index.php/2009/11/26/asp-net-structuremap-epic-win/</guid>
		<description><![CDATA[After running into a lot of testing problems with my current architecture in ASP.NET, I decided that it was time to look into an IoC Framework. I have heard the marvels of how it makes code so much more isolated and clean (SOLID), but I couldn’t see my code ever getting to this point. Because [...]]]></description>
			<content:encoded><![CDATA[<p>After running into a lot of testing problems with my current architecture in ASP.NET, I decided that it was time to look into an IoC Framework.  I have heard the marvels of how it makes code so much more isolated and clean (SOLID), but I couldn’t see my code ever getting to this point.  Because this project has a ton of legacy code, there was little incentive to add anything else when it was already so highly coupled.  I needed to take a step back and look at it from a different perspective.</p>
<p>I understood how IoC (Inversion of Control) Frameworks worked and knew how this technique is used, but I didn’t know how I could integrate it in my application.  Most of my action/service methods were static classes that instantiated new objects to return what I needed.</p>
<p>Here’s an example:</p>
<p>On the member page, there is a list of upcoming conferences that calls this code:</p>
<pre class="brush: vb">Public Class ConferenceService    

	Public Shared Function GetUpcomingConferences(ByVal DisplayDate As DateTime) As IList(Of ConferenceEntity)
		Using repo As New Repository
			Dim bucket As New RelationPredicateBucket(ConferenceFields.IsActive = True)
            Dim startfilter As New PredicateExpression(ConferenceFields.StartDisplayDate = System.DBNull.Value)
			startfilter.AddWithOr(ConferenceFields.StartDisplayDate &lt;= DisplayDate)
			bucket.PredicateExpression.AddWithAnd(startfilter)         

			Dim endfilter As New PredicateExpression(ConferenceFields.EndDisplayDate = System.DBNull.Value)
			endfilter.AddWithOr(ConferenceFields.EndDisplayDate &gt;= DisplayDate)
			bucket.PredicateExpression.AddWithAnd(endfilter)
			Dim sorter As New SortExpression(ConferenceFields.StartDateTimeUtc Or SortOperator.Ascending)
			Return repo.GetCollection(Of ConferenceEntity)(bucket, sorter).ToList()
		End Using
	End Function

End Class</pre>
<p>I am using LLBLGen (Adapter) as my DAL so the Repository class is responsible for calling a new object to create what LLBLGen calls an EntityCollection.  This is easy to call because all I have to do is call ConferenceService.GetUpcomingConferences(Date.Now()) to get a list of upcoming conference.  This is very hard to test though without using something like Typemock.</p>
<p>In order to start my refactoring to be able to integrate StructureMap, I needed to look at how my ConferenceService was being constructed.  There are 5 constructor calls in this method alone. You can imagine how the rest of the application looks like.</p>
<h3>Adding and Setting Up StructureMap</h3>
<p>First, download StructureMap from the website.  I downloaded version 2.5.3.  Next was to look how to get StructureMap set up on the web project (found here <a title="http://structuremap.sourceforge.net/ConfiguringStructureMap.htm" href="http://structuremap.sourceforge.net/ConfiguringStructureMap.htm">http://structuremap.sourceforge.net/ConfiguringStructureMap.htm</a>).  I had to use for VB and lambdas are tricky so this is how the Bootstrapper was defined:</p>
<pre class="brush: vb">Imports StructureMap
Imports StructureMap.Configuration.DSL

Public Class Bootstrapper    

	Public Shared Sub BootstrapStructureMap()
		ObjectFactory.Initialize(AddressOf ConfigStructureMap)
	End Sub    

	Private Shared Sub ConfigStructureMap(ByVal x As IInitializationExpression)
		x.AddRegistry(New RepositoryRegistry)
	End Sub    

	Public Class RepositoryRegistry
		Inherits Registry        

		Overrides Protected Sub configure()
			'Will be used later after we refactor
			'ForRequestedType(Of IRepository)().TheDefaultIsConcreteType(Of Repository)().CacheBy(Attributes.InstanceScope.Hybrid)
		End Sub   

	 End Class
 End Class</pre>
<p>And then, in our Global.asax, on the Application_Start, call the Bootstrapper.BootstrapStructureMap() method. That is all we need for StructureMap config for now.  That will get us started in the right direction.</p>
<h3><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="image" src="http://www.mindgravy.net/wp-content/uploads/2009/11/image.png" border="0" alt="image" width="349" height="168" align="right" />Refactoring</h3>
<p>The first refactoring is to Extract an Interface from the Repository class.  If you have a refactoring tool such as Refactor Pro! or Resharper, this is made very easy.  I called mine, <strong>IRepository</strong>.  This will make the Repository class implement the newly created interface.  We can now start on the ConferenceService.</p>
<p>The next refactoring is to create a constructor for the ConferenceService class that takes an IRepository as a parameter.  This will help us create Constructor Injection.</p>
<p>After we add the parameter, we can remove the code that uses the concrete Repository object.</p>
<pre class="brush: vb"> Public Class ConferenceService   

	 Private _repo As IRepository
	 ''' &lt;summary&gt;
	 ''' Initializes a new instance of the ConferenceService class.
	 ''' &lt;/summary&gt;
	 ''' &lt;param name="repo"&gt;&lt;/param&gt;
	 Public Sub New(ByVal repo As IRepository)
		_repo = repo
	 End Sub    

	 Public Function GetUpcomingConferences(ByVal DisplayDate As DateTime) As IList(Of ConferenceEntity)
		 Dim bucket As New RelationPredicateBucket(ConferenceFields.IsActive = True)
		 im startfilter As New PredicateExpression(ConferenceFields.StartDisplayDate = System.DBNull.Value)
		 startfilter.AddWithOr(ConferenceFields.StartDisplayDate &lt;= DisplayDate)
		 bucket.PredicateExpression.AddWithAnd(startfilter)
		 Dim endfilter As New PredicateExpression(ConferenceFields.EndDisplayDate = System.DBNull.Value)
		 endfilter.AddWithOr(ConferenceFields.EndDisplayDate &gt;= DisplayDate)
		 bucket.PredicateExpression.AddWithAnd(endfilter)
		 Dim sorter As New SortExpression(ConferenceFields.StartDateTimeUtc Or SortOperator.Ascending)
		 Return _repo.GetCollection(Of ConferenceEntity)(bucket, sorter).ToList()
	End Function   

 End Class</pre>
<p>The next piece of code is back in our Bootstrapper that we have to uncomment.</p>
<pre class="brush: vb">'ForRequestedType(Of IRepository)().TheDefaultIsConcreteType(Of Repository)().CacheBy(Attributes.InstanceScope.Hybrid)</pre>
<p>Now, instead of calling the static method as such:</p>
<pre class="brush: vb">Dim upcomingConf as IList(Of ConferenceEntity) = ConferenceService.GetUpcomingConferences(Date.Now())</pre>
<p>We can call it as such:</p>
<pre class="brush: vb">Dim upcomingConf as IList(Of ConferenceEntity) = _new ConferenceService(ObjectFactory.GetInstance(Of IRepository)()).GetUpcomingConferences(Date.Now())</pre>
<p>This allows us to decouple the concrete Repository object and allows for testing out our method. We’ll be able to write tests now to cover our legacy code, and allow for more flexible code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mindgravy.net/2009/11/26/asp-net-structuremap-epic-win/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ketchup/Catsup</title>
		<link>http://www.mindgravy.net/2009/09/27/ketchupcatsup/</link>
		<comments>http://www.mindgravy.net/2009/09/27/ketchupcatsup/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 05:28:11 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.mindgravy.net/index.php/2009/09/27/ketchupcatsup/</guid>
		<description><![CDATA[Yes ladies and gentlemen, I am still here, albeit very busy. I thought I would just post to let you know what is going on.&#160; Work has taken over since I was given a deadline of 6 weeks after an estimate of 4 months.&#160; You can assume that I am now knee deep in crap [...]]]></description>
			<content:encoded><![CDATA[<p>Yes ladies and gentlemen, I am still here, albeit very busy.</p>
<p>I thought I would just post to let you know what is going on.&#160; Work has taken over since I was given a deadline of 6 weeks after an estimate of 4 months.&#160; You can assume that I am now knee deep in crap code and worst practices.&#160; </p>
<p><img title="Conner" style="border-right: 0px; border-top: 0px; display: inline; margin-left: 0px; border-left: 0px; margin-right: 0px; border-bottom: 0px" height="184" alt="Conner" src="http://www.mindgravy.net/images/KetchupCatsup_684/DSC06032.jpg" width="244" align="right" border="0" />Conner is keeping me busy as always and every day is a new chapter in his life that surprises me.&#160; I would never think that I would ever have this kind of influence on anyone.&#160; It’s amazing.</p>
<p>I have been trying to learn more about ASP.NET MVC but I have not been able to put as much effort into it as I would like.</p>
<p>I realized that this coming Thanksgiving will be the 3 year anniversary of me quitting smoking.&#160; </p>
<p>I have started back on Weightwatchers with Debbie and we are doing well.&#160; I have already lost 25 lbs in 3 months.&#160; I hope to have reached my goal by Christmas, so you might be seeing a new Steve in the future.&#160; I feel great and I really hope to keep it off.&#160; You can follow my progress on my <a href="http://search.twitter.com/search?q=from%3Aunderwhelmed+%23TodaysWeight">twitter</a> (Thanks to <a href="http://jasonbock.net/JB/Default.aspx">Jason Bock</a> for the idea)</p>
<p>That is all for now, I want to start posting more but Twitter seems to have taken a lot from me since I don’t have much to say here other than little quips here and there.&#160; </p>
<p>~~S</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mindgravy.net/2009/09/27/ketchupcatsup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
