<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5192407982178004818</id><updated>2011-11-28T01:01:05.668+01:00</updated><category term='CodeProject'/><title type='text'>Follow the Yellow Brick Road</title><subtitle type='html'>Giorgio Bozio's programming journeys</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://letsfollowtheyellowbrickroad.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192407982178004818/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://letsfollowtheyellowbrickroad.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Giorgio Bozio</name><uri>http://www.blogger.com/profile/17360372948342890640</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://4.bp.blogspot.com/_nUoHI0k1B7E/S8oo7PX_iwI/AAAAAAAAAIw/Kzo8gIxoDvY/S220/GB.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5192407982178004818.post-3565016330894187844</id><published>2010-05-16T15:14:00.019+02:00</published><updated>2010-12-20T19:35:41.777+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CodeProject'/><title type='text'>NHibernate sessions in ASP.NET MVC</title><content type='html'>&lt;br/&gt;&lt;br /&gt;If you've used &lt;a href="http://nhforge.org/"&gt;NHibernate&lt;/a&gt; in a &lt;a href="http://www.asp.net/mvc"&gt;ASP.NET MVC&lt;/a&gt; project you probably encountered the problem of keeping session open in the view in order to retrieve model data. (even though if session is open then the view actually makes calls to the db under the hood, which maybe is not very MVC. But that's another story)&lt;br /&gt;&lt;br /&gt;The idea is to pass controllers an instance of a NHibernate session which is unique for the http request.&lt;br /&gt;&lt;br /&gt;First off we need to "hijack" the ASP.NET mechanism that instantiate controllers to pass something in the constructor. In this case it's a ISession, but it could well be a repository class (which in turn gets a ISession passed in its constructor).&lt;br /&gt;&lt;br /&gt;So a controller would look like this:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public class MyController : Controller&lt;br /&gt;{&lt;br /&gt;    ISession session;&lt;br /&gt;&lt;br /&gt;    public MyController(ISession session)&lt;br /&gt;    {&lt;br /&gt;        this.session = session;&lt;br /&gt;    }&lt;br /&gt;...&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I've used &lt;a href="http://unity.codeplex.com/"&gt;Unity&lt;/a&gt; dependency container to manage the instantiation of controllers. ASP.NET MVC lets you do that by overriding the DefaultControllerFactory.&lt;br /&gt;&lt;br /&gt;This is as simple as writing this class:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public class UnityControllerFactory : DefaultControllerFactory&lt;br /&gt;{&lt;br /&gt;    UnityContainer container;&lt;br /&gt;&lt;br /&gt;    public UnityControllerFactory(UnityContainer container)&lt;br /&gt;    {&lt;br /&gt;        this.container = container;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)&lt;br /&gt;    {&lt;br /&gt;        IController controller = null;&lt;br /&gt;        if (controllerType != null)&lt;br /&gt;        {&lt;br /&gt;            controller = this.container.Resolve(controllerType) as IController;&lt;br /&gt;        }&lt;br /&gt;        return controller;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;To make the session instance "singleton" for the http request, all I need to do is write a simple custom lifetime manager for Unity:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public class PerRequestLifetimeManager : LifetimeManager&lt;br /&gt;{&lt;br /&gt;    public const string Key = "SingletonPerRequest";&lt;br /&gt;&lt;br /&gt;    public override object GetValue()&lt;br /&gt;    {&lt;br /&gt;        return HttpContext.Current.Items[Key];&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public override void SetValue(object newValue)&lt;br /&gt;    {&lt;br /&gt;        HttpContext.Current.Items[Key] = newValue;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public override void RemoveValue() {} // this does not appear to be used ...&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Let's get everything together in Global.asax. We need to register NHibernate ISession in Unity configuration. It should inject it using a factory method (OpenSession method of a ISessionFactory instance).&lt;br /&gt;&lt;br /&gt;Then we need to tell MVC to use our Controller factory, passing the Unity container of our ASP.NET MVC application.&lt;br /&gt;&lt;br /&gt;To close open NHibernate sessions we add some code in the Application_EndRequest.&lt;br /&gt;&lt;br /&gt;Here's the code to put in our Global.asax file.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;protected void Application_Start()&lt;br /&gt;{&lt;br /&gt;    this.container = new UnityContainer();&lt;br /&gt;    ISessionFactory sessionFactory = NHConfigurator.CreateSessionFactory(); &lt;br /&gt;    // NHConfigurator is my helper conf class&lt;br /&gt;&lt;br /&gt;    container.RegisterType&lt;ISession&gt;(&lt;br /&gt;        new PerRequestLifetimeManager(),&lt;br /&gt;        new InjectionFactory(c =&gt; {&lt;br /&gt;            return sessionFactory.OpenSession();&lt;br /&gt;        }));&lt;br /&gt;&lt;br /&gt;    ControllerBuilder.Current.SetControllerFactory(new UnityControllerFactory &lt;br /&gt;(this.container));&lt;br /&gt;&lt;br /&gt;    AreaRegistration.RegisterAllAreas();&lt;br /&gt;&lt;br /&gt;    RegisterRoutes(RouteTable.Routes);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;protected void Application_EndRequest(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;    Object sessionObject = HttpContext.Current.Items[PerRequestLifeTimeManager.Key];&lt;br /&gt;    if (sessionObject != null)&lt;br /&gt;    {&lt;br /&gt;        ISession currentSession = sessionObject as ISession;&lt;br /&gt;        if (currentSession != null)&lt;br /&gt;        {&lt;br /&gt;            currentSession.Close();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}       &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Hope this helps!&lt;br /&gt;&lt;br /&gt;&lt;div class="shoutIt"&gt;&lt;br /&gt;    &lt;a rev="vote-for" href="http://dotnetshoutout.com/Submit?url=http://letsfollowtheyellowbrickroad.blogspot.com/2010/05/nhibernate-sessions-in-aspnet-mvc.html"&gt;&lt;br /&gt;        &lt;img alt="Shout it" src="http://dotnetshoutout.com/image.axd?url=http://letsfollowtheyellowbrickroad.blogspot.com/2010/05/nhibernate-sessions-in-aspnet-mvc.html" style="border:0px"/&gt;&lt;br /&gt;    &lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fletsfollowtheyellowbrickroad.blogspot.com%2f2010%2f05%2fnhibernate-sessions-in-aspnet-mvc.html"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fletsfollowtheyellowbrickroad.blogspot.com%2f2010%2f05%2fnhibernate-sessions-in-aspnet-mvc.html" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5192407982178004818-3565016330894187844?l=letsfollowtheyellowbrickroad.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://letsfollowtheyellowbrickroad.blogspot.com/feeds/3565016330894187844/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://letsfollowtheyellowbrickroad.blogspot.com/2010/05/nhibernate-sessions-in-aspnet-mvc.html#comment-form' title='18 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192407982178004818/posts/default/3565016330894187844'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192407982178004818/posts/default/3565016330894187844'/><link rel='alternate' type='text/html' href='http://letsfollowtheyellowbrickroad.blogspot.com/2010/05/nhibernate-sessions-in-aspnet-mvc.html' title='NHibernate sessions in ASP.NET MVC'/><author><name>Giorgio Bozio</name><uri>http://www.blogger.com/profile/17360372948342890640</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://4.bp.blogspot.com/_nUoHI0k1B7E/S8oo7PX_iwI/AAAAAAAAAIw/Kzo8gIxoDvY/S220/GB.jpg'/></author><thr:total>18</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192407982178004818.post-5330274936981088951</id><published>2010-04-17T15:40:00.019+02:00</published><updated>2010-08-06T15:18:27.548+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CodeProject'/><title type='text'>MaToMaTo - Windows Pomodoro Timer</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_nUoHI0k1B7E/S8nOhMZqrZI/AAAAAAAAAIk/esIgwO9YLvY/s1600/Screenshot.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 255px; height: 244px;" src="http://2.bp.blogspot.com/_nUoHI0k1B7E/S8nOhMZqrZI/AAAAAAAAAIk/esIgwO9YLvY/s400/Screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5461123092823322002" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;This page is obsolete. Please go to the &lt;a href="http://www.vivasoftware.it/PomodoroTimer/MaToMaTo/"&gt;new home of the MaToMaTo&lt;/a&gt; pomodoro timer.&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;MaToMaTo is a Windows  animated &lt;a href="http://www.pomodorotechnique.com/"&gt;Pomodoro Technique&lt;/a&gt; timer. It's made in WPF so you'll need .Net 3.5 to run it.&lt;br /&gt;&lt;br /&gt;It's simple, yet IMHO, it fulfills all the ideal requirements of a pomodoro timer.&lt;br /&gt;&lt;br /&gt;It has no activities manager since you're supposed to manage them on paper. It just acts as a timer with fixed 25 minutes elapsed time.&lt;br /&gt;&lt;br /&gt;Main features are:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;It stays on top of all windows, so you're able to always see it even if working on MS word, Visual Studio or anything you're working on to complete your pomodoro task.&lt;/li&gt;&lt;li&gt;It doesn't make any tick or other noise, so it's ideal when working on open spaces with other people.&lt;/li&gt;&lt;li&gt;It is animated, it swings every second for the first 20 minutes of the pomodoro. The last 5 minutes, it pulses like a tomato-heart :-)&lt;/li&gt;&lt;li&gt;It's not possible to stop and restart a pomodoro. Restarting one puts the timer back to 25.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;You can download it here as a zip file: &lt;span style="font-weight:bold;"&gt;&lt;a href="http://www.vivasoftware.it/en/Matomato/Download"&gt;MaToMato.zip&lt;/a&gt;&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;No setup needed. Simply unzip, start the executable and enjoy our crazy MaToMaTo!&lt;br /&gt;&lt;br /&gt;The MaToMaTo concept is mine but I should give most of the credits to &lt;a href="http://it.linkedin.com/in/federicacuccolo"&gt;Federica Cuccolo&lt;/a&gt;, she did all the coding and the artwork, terrific work, thanks Fefy!&lt;br /&gt;&lt;br /&gt;Any feedback will be appreciated! Please let us know what you think by posting a comment to this post.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5192407982178004818-5330274936981088951?l=letsfollowtheyellowbrickroad.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://letsfollowtheyellowbrickroad.blogspot.com/feeds/5330274936981088951/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://letsfollowtheyellowbrickroad.blogspot.com/2010/04/matomato-windows-pomodoro-timer.html#comment-form' title='16 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192407982178004818/posts/default/5330274936981088951'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192407982178004818/posts/default/5330274936981088951'/><link rel='alternate' type='text/html' href='http://letsfollowtheyellowbrickroad.blogspot.com/2010/04/matomato-windows-pomodoro-timer.html' title='MaToMaTo - Windows Pomodoro Timer'/><author><name>Giorgio Bozio</name><uri>http://www.blogger.com/profile/17360372948342890640</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://4.bp.blogspot.com/_nUoHI0k1B7E/S8oo7PX_iwI/AAAAAAAAAIw/Kzo8gIxoDvY/S220/GB.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_nUoHI0k1B7E/S8nOhMZqrZI/AAAAAAAAAIk/esIgwO9YLvY/s72-c/Screenshot.png' height='72' width='72'/><thr:total>16</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192407982178004818.post-4515623932056243873</id><published>2010-04-10T22:48:00.013+02:00</published><updated>2010-04-11T12:30:48.026+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CodeProject'/><title type='text'>Unit testing and the "constructors do nothing" rule</title><content type='html'>&lt;br/&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Introduction&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Writing unit testing code is really easy.&lt;br /&gt;&lt;br /&gt;It's not much more then writing some client code of the library you want to test and add some assert calls to check (test) if the code works as expected. With C# now we have lots of alternatives to do that.&lt;br /&gt;&lt;br /&gt;But is it just that?&lt;br /&gt;&lt;br /&gt;Not really!&lt;br /&gt;&lt;br /&gt;Let's briefly look at some principles behind unit testing.&lt;br /&gt;&lt;br /&gt;A unit test, as the name implies, should test just a unit a code. If it doesn't and it ends up depending on some other code then it becomes hard to tell why the test passes or not.&lt;br /&gt;Also, depending on other code makes test hard to make repeatable. Just think about testing a method that depends on some database operation, now you should take care of maintaing database state over repeated calls to your test suite.&lt;br /&gt;&lt;br /&gt;Being able to isolate units of code not also makes it more testable but also easier to work with and to refactor.&lt;br /&gt;&lt;br /&gt;This post will try to explain some good practices to make your C# code more testable.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Constructors should do nothing&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is an important rule you should enforce if you want your code to be testable. It also makes it easier to enforce SRP (Single Responsibility Principle).&lt;br /&gt;In the class constructor, objects should not be created, because if they are then your class becomes coupled to them and you are not able to inject testing objects during unit testing.&lt;br /&gt;&lt;br /&gt;Lets jump to some sample code.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;    public class StringsCalculator&lt;br /&gt;    {&lt;br /&gt;        public int Sum(string x, string y)&lt;br /&gt;        {&lt;br /&gt;            int xi = 0;&lt;br /&gt;            int yi = 0;&lt;br /&gt;            int result = 0;&lt;br /&gt;            if (int.TryParse(x, out xi) &amp;&amp; int.TryParse(y, out yi))&lt;br /&gt;            {&lt;br /&gt;                result = xi + yi;&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                throw new ArgumentException("Strings passed are not integers.");&lt;br /&gt;            }&lt;br /&gt;            return result;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This class StringsCalculator contains a method Sum that takes two strings and tries to sum them if the can be parsed as numbers. It clearly does two things, converting strings to integers and summing them. So if we want to test does separatly we should separate the two responsibilities. Perhaps separating the string conversion in a class StringToNumber:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;    public class StringToNumber&lt;br /&gt;    {&lt;br /&gt;        public int Convert(string stringNumber)&lt;br /&gt;        {&lt;br /&gt;            int result = 0;&lt;br /&gt;            if (!int.TryParse(stringNumber, out result))&lt;br /&gt;            {&lt;br /&gt;                throw new ArgumentException("String is not a number");&lt;br /&gt;            }&lt;br /&gt;            return result;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Thus we can refactor our StringsCalculator class:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;    public class StringsCalculator&lt;br /&gt;    {&lt;br /&gt;        StringToNumber stringToNumber;&lt;br /&gt;&lt;br /&gt;        public StringsCalculator()&lt;br /&gt;        {&lt;br /&gt;            this.stringToNumber = new StringToNumber();&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        public int Sum(string x, string y)&lt;br /&gt;        {&lt;br /&gt;            return stringToNumber.Convert(x) + stringToNumber.Convert(y);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This looks better, but what about our test:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;        [Test]&lt;br /&gt;        public void SumStringsNotTestable()&lt;br /&gt;        {&lt;br /&gt;            StringsCalculator ss = new StringsCalculator();&lt;br /&gt;            int result = ss.Sum("2", "3");&lt;br /&gt;            Assert.AreEqual(5, result);&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;It tests our class but this way it tests also the StringToNumber class so it's really not "unit" testing.&lt;br /&gt;&lt;br /&gt;So let's follow the "Constructors do nothing" rule by doing some refactoring.&lt;br /&gt;&lt;br /&gt;First off let's separate the two classes by putting a interface between them. In Visual Studio we just need to right click on the StringToNumber class and choose Refactor-&gt;Extract interface... and name it IStringToNumber. Next we need modify the StringsCalculator constructor to accept a parameter of type IStringToNumber.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;    public class StringsCalculator&lt;br /&gt;    {&lt;br /&gt;        IStringToNumber stringToNumber;&lt;br /&gt;&lt;br /&gt;        public StringsCalculator(IStringToNumber stringToNumber)&lt;br /&gt;        {&lt;br /&gt;            this.stringToNumber = stringToNumber;&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        public int Sum(string x, string y)&lt;br /&gt;        {&lt;br /&gt;            return stringToNumber.Convert(x) + stringToNumber.Convert(y);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Mocking objects&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now we can refactor our test to instantiate the StringsCalculator object by passing to its constructor a mock object and not a StringToNumber object. To do this we can use one of the many mocking frameworks for .Net around. I chose the very nice RhinoMocks library, that's easy to use and quite complete. So here's our new test:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;        [Test]&lt;br /&gt;        public void SumStringsTest()&lt;br /&gt;        {&lt;br /&gt;            MockRepository mocks = new MockRepository();&lt;br /&gt;            IStringToNumber stringToNumber = mocks.StrictMock&lt;IStringToNumber&gt;();&lt;br /&gt;            StringsCalculator ss = new StringsCalculator(stringToNumber);&lt;br /&gt;            Expect.Call(stringToNumber.Convert("2")).Return(2);&lt;br /&gt;            Expect.Call(stringToNumber.Convert("3")).Return(3);&lt;br /&gt;            mocks.ReplayAll();&lt;br /&gt;            int result = ss.Sum("2", "3");&lt;br /&gt;            Assert.AreEqual(5, result);&lt;br /&gt;            mocks.VerifyAll();&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As you can see we can instruct the RhinoMocks repository to expect two calls to the IStringToNumber. In this way we are able to verify the inner workings our our class, thus doing what is called white-box testing by calling the VerifyAll() method.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Constructor injection&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Having all collaborators classes passed in as constructor parameters enables us to decouple nicely and test in isolation. But what about the client code using this classes, do they have to do lots of code to instantiate all those collaborators? Well there's a nice solution to this, dependency injection containers. In my case I'll use Unity, by using it to instantiate objects, client code doesn't have to prepare alkl those collaborators, Unity will take care of it, even in cascade if those collaborators themselves have other collaborators as constructor parameters. We can implement a integration test to verify our classes together:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;        [Test]&lt;br /&gt;        public void SumStringsUnityTest()&lt;br /&gt;        {&lt;br /&gt;            UnityContainer container = new UnityContainer();&lt;br /&gt;            UnityConfigurationSection section =&lt;br /&gt;                (UnityConfigurationSection)ConfigurationManager.GetSection("unity");&lt;br /&gt;&lt;br /&gt;            section.Containers.Default.Configure(container);&lt;br /&gt;&lt;br /&gt;            IStringToNumber stringToNumber = container.Resolve&lt;IStringToNumber&gt;();&lt;br /&gt;            StringsCalculator ss = new StringsCalculator(stringToNumber);&lt;br /&gt;            int result = ss.Sum("2", "3");&lt;br /&gt;            Assert.AreEqual(5, result);&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Unity configuration code could be conveniently located in a helper class.&lt;br /&gt;&lt;br /&gt;So, to summarize, we can say: Constructors do nothing, all collaborators are passed in as parameters so we can mock them in unit tests and let a dependency injection mechanism compose them in client code.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5192407982178004818-4515623932056243873?l=letsfollowtheyellowbrickroad.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://letsfollowtheyellowbrickroad.blogspot.com/feeds/4515623932056243873/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://letsfollowtheyellowbrickroad.blogspot.com/2010/04/unit-testing-really.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192407982178004818/posts/default/4515623932056243873'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192407982178004818/posts/default/4515623932056243873'/><link rel='alternate' type='text/html' href='http://letsfollowtheyellowbrickroad.blogspot.com/2010/04/unit-testing-really.html' title='Unit testing and the &quot;constructors do nothing&quot; rule'/><author><name>Giorgio Bozio</name><uri>http://www.blogger.com/profile/17360372948342890640</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://4.bp.blogspot.com/_nUoHI0k1B7E/S8oo7PX_iwI/AAAAAAAAAIw/Kzo8gIxoDvY/S220/GB.jpg'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192407982178004818.post-8440364951799959910</id><published>2009-11-02T15:27:00.041+01:00</published><updated>2009-11-03T20:16:09.659+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CodeProject'/><title type='text'>Separating layers and components with constructor injection and Unity</title><content type='html'>Ok, so how did I come to using Unity and constructor injection?&lt;br /&gt;&lt;br /&gt;Anyway ... what is Unity? And what is constructor injection?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Unity &lt;/span&gt; is a "dependency injection container", (see http://www.codeplex.com/unity/ for details) in other words it is a library that implements mechanisms to easily apply the dependency injection pattern.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Dependency injection&lt;/span&gt; is a design pattern that aims at separating concerns, like separating from the application specific domain all the other concerns that are not strictly "about" the topic of the application (usually are more low level).&lt;br /&gt;&lt;br /&gt;For example in a mp3 player app, connecting to the db to save personal info about the songs is not something that affects software functionality. If the db app changes or we decide that the info is going to be stored to a remote server through a web service, the functionality will still be there and the app will continue to work. It would be different if we wanted our app to be able to play iTunes audio books. That would be a change that affects the domain of the app.&lt;br /&gt;&lt;br /&gt;So it's a valuable thing if we can separate those facet of the application from the "real" functionalities. This separation enables us to think more clearly and in a clean way about our application and not mix different concerns. Also we can unit test better and apply test driven development.&lt;br /&gt;&lt;br /&gt;Let's see a sample app. What about the dear old "Hello world" functionality?! This app is about... saying hello... to you.. :-)&lt;br /&gt;By the way this time we are going to log who are we saying hello to. How and where we are going to store this info is not really relevant to the app. We just want to able to call a method like Log(message), in the HelloWorld method of our class (MainClass, forgive the ugly name..):&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;   public class MainClass&lt;br /&gt;   {&lt;br /&gt;       ILogger logger;&lt;br /&gt;&lt;br /&gt;       public MainClass(ILogger logger)&lt;br /&gt;       {&lt;br /&gt;           this.logger = logger;&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       public string HelloWorld(string name)&lt;br /&gt;       {&lt;br /&gt;           string helloMessage = "Hello " + name + "!";&lt;br /&gt;           this.logger.Log("Said hello to " + name + "!");&lt;br /&gt;           return helloMessage;&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;HelloWorld calls the Log method of an object implementing the ILogger interface. This way our application is not dependent upon a specific logger implementation, hence the inversion of dependency, the main application doesn't depend on the loggr, it's the logger that depends upon the ILogger interface defined by the app.&lt;br /&gt;&lt;br /&gt;Here's a quick look to how the visual studio solution looks like:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_nUoHI0k1B7E/Su8FCjSNcpI/AAAAAAAAAG4/KqTWaGbsuok/s1600-h/VSSolution.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; cursor: pointer; width: 247px; height: 400px;" src="http://1.bp.blogspot.com/_nUoHI0k1B7E/Su8FCjSNcpI/AAAAAAAAAG4/KqTWaGbsuok/s400/VSSolution.png" alt="" id="BLOGGER_PHOTO_ID_5399540019630011026" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;It's very simple, we have a UnitySampleUse project, a MyLogger project and the test project UnitySampleUse.Test.&lt;br /&gt;&lt;br /&gt;UnitySampleUse contains the ILogger interface. MyLogger contains MyLoggerClass that implements ILogger, so MyLogger contains a reference to UnitySampleUse. If we where going to instantiate a MyLoggerClass object inside UnitySampleUse we would have to reference and we don't want to make ou app depent upon MyLogger (plus we would have circular reference).&lt;br /&gt;&lt;br /&gt;So who's going to glue things together and pass a ILogger object to UnitySampleUse?&lt;br /&gt;Guess what... Unity!&lt;br /&gt;&lt;br /&gt;The client of our code, in this case the test project (it could be a UI project or another library), uses Unity to instantiate ILogger, automagically composing our MainClass, passing in the constructor the concrete object implementing ILogger.&lt;br /&gt;The mapping of the interface to the class implementing it can be stored in the xml config file (app.config), that, in our case, will look like this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;&lt;br /&gt;&amp;lt;configuration&amp;gt;&lt;br /&gt;  &amp;lt;configSections&amp;gt;&lt;br /&gt;    &amp;lt;section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection,Microsoft.Practices.Unity.Configuration, Version=1.2.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35"/&amp;gt;&lt;br /&gt;  &amp;lt;/configSections&amp;gt;&lt;br /&gt;&lt;br /&gt;  &amp;lt;unity&amp;gt;&lt;br /&gt;    &amp;lt;typeAliases&amp;gt;&lt;br /&gt;      &amp;lt;!-- Lifetime manager types should be inserted if you need lifetime managers --&amp;gt;&lt;br /&gt;      &amp;lt;typeAlias alias="singleton" type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager,Microsoft.Practices.Unity"/&amp;gt;&lt;br /&gt;      &amp;lt;typeAlias alias="external" type="Microsoft.Practices.Unity.ExternallyControlledLifetimeManager,Microsoft.Practices.Unity"/&amp;gt;&lt;br /&gt;      &amp;lt;!-- User defined type aliases --&amp;gt;&lt;br /&gt;      &amp;lt;typeAlias alias="ILogger" type="UnitySampleUse.ILogger,UnitySampleUse"/&amp;gt;&lt;br /&gt;    &amp;lt;/typeAliases&amp;gt;&lt;br /&gt;    &amp;lt;containers&amp;gt;&lt;br /&gt;      &amp;lt;container&amp;gt;&lt;br /&gt;        &amp;lt;types&amp;gt;&lt;br /&gt;          &amp;lt;type type="ILogger" mapTo="MyLogger.MyLoggerClass, MyLogger"&amp;gt;&lt;br /&gt;          &amp;lt;/type&amp;gt;&lt;br /&gt;        &amp;lt;/types&amp;gt;&lt;br /&gt;      &amp;lt;/container&amp;gt;&lt;br /&gt;    &amp;lt;/containers&amp;gt;&lt;br /&gt;  &amp;lt;/unity&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/configuration&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The test will need to instantiate the MainClass using Unity:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;UnityContainer container = new UnityContainer();&lt;br /&gt;UnityConfigurationSection section =&lt;br /&gt;        (UnityConfigurationSection)ConfigurationManager.GetSection("unity");&lt;br /&gt;&lt;br /&gt;section.Containers.Default.Configure(container);&lt;br /&gt;&lt;br /&gt;MainClass mainClass= container.Resolve&amp;lt;MainClass&amp;gt;(); &lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Unity will take care of calling the constructor MainClass(ILogger logger), injecting a MyLoggerClass object. Thus the type of dependency injection applied is &lt;span style="font-weight:bold;"&gt;constructor injection&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;UnitySampleUse project can be compiled without having the source code of the logger and the client code (the unit test, or the ui etc) can switch logger implementation without change in the code by just referencing the new logger and updating the config file.&lt;br /&gt;&lt;br /&gt;This way we can separate layers, for example our data access layer, very easily and at the same time keep all our application logic in one project.&lt;br /&gt;&lt;br /&gt;Separating layers and building by components has never been easier.&lt;br /&gt;&lt;br /&gt;&lt;small&gt;This post is published on &lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=5024022" rel="tag"&gt;CodeProject&lt;/a&gt;&lt;/small&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5192407982178004818-8440364951799959910?l=letsfollowtheyellowbrickroad.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://letsfollowtheyellowbrickroad.blogspot.com/feeds/8440364951799959910/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://letsfollowtheyellowbrickroad.blogspot.com/2009/11/separating-layers-with-constructor.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192407982178004818/posts/default/8440364951799959910'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192407982178004818/posts/default/8440364951799959910'/><link rel='alternate' type='text/html' href='http://letsfollowtheyellowbrickroad.blogspot.com/2009/11/separating-layers-with-constructor.html' title='Separating layers and components with constructor injection and Unity'/><author><name>Giorgio Bozio</name><uri>http://www.blogger.com/profile/17360372948342890640</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://4.bp.blogspot.com/_nUoHI0k1B7E/S8oo7PX_iwI/AAAAAAAAAIw/Kzo8gIxoDvY/S220/GB.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_nUoHI0k1B7E/Su8FCjSNcpI/AAAAAAAAAG4/KqTWaGbsuok/s72-c/VSSolution.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192407982178004818.post-1384957881208845123</id><published>2009-03-25T22:43:00.020+01:00</published><updated>2009-07-09T09:00:57.502+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CodeProject'/><title type='text'>Prototyping with Pencil and Powerpoint</title><content type='html'>I found myself in the need to produce functional specifications for a module of a web application. The requirement was to build some fake screen shots to give the client a representation of how the software will look like.&lt;br /&gt;&lt;br /&gt;In past projects I tried paper prototyping, with mixed results and visio diagrams. &lt;br /&gt;&lt;br /&gt;This time I looked around to see if some other tool was available and I found &lt;a href="http://www.evolus.vn/Pencil/"&gt;Pencil&lt;/a&gt;. It's a Firefox 3 plugin that uses the Mozilla Gecko engine. I should say I was really delighted by the simplicity of the tool and the power it gives in building prototypes/wireframes. I was able to be productive in minutes and the results were really good.&lt;br /&gt;&lt;br /&gt;You can draw UI shapes, align and resize them with ease and organize them in pages. Then you can batch export those pages as PNG images in a folder. All with just a few clicks.&lt;br /&gt;&lt;br /&gt;After doing this I built some detailed spec about how those pages interacted one with each other in a Word document. I was putting every single atomic user interaction down, in numbered points, using the point numbers as anchor reference between points.&lt;br /&gt;As I was doing this I thought it would be more effective if I could just make this really interactive. So it came to my mind I could simply use PowerPoint to achieve this.&lt;br /&gt;&lt;br /&gt;It turned out as simple as this: &lt;br /&gt;- I used a print screen of the web app that is going to host the new module, cleaned the body with Gimp and keep just the background color and header and footer.&lt;br /&gt;- Put this image as the background for the PowerPoint slides.&lt;br /&gt;- Insert each PNG image obtained from &lt;a href="http://www.evolus.vn/Pencil/"&gt;Pencil&lt;/a&gt; in single slides.&lt;br /&gt;- Draw a transparent rectangle (no fill, you can make them transparent by default) on the areas where you want to enable the user to click, for example on a button of a Pencil generated png image.&lt;br /&gt;- On this rectangle, right mouse click and choose "Action settings".&lt;br /&gt;- On the "Action settings" pane you can choose the "Hyperlink to:" option and define the slide to send to upon clicking the rectangle. On the Mouse over tab check the Highligh mouse over option.&lt;br /&gt;- You can also disable clicks on the slide to take viewer on the next slide by selecting 'Slideshow' menu, 'Slide transition' and then uncheck the option that says 'Advance on mouse click'. You can also add a smooth transition and apply on all slides,&lt;br /&gt;&lt;br /&gt;This method is really basic and simple, but the results can be quite realistic.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5192407982178004818-1384957881208845123?l=letsfollowtheyellowbrickroad.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://letsfollowtheyellowbrickroad.blogspot.com/feeds/1384957881208845123/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://letsfollowtheyellowbrickroad.blogspot.com/2009/03/prototyping-with-pencil-and-powerpoint.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192407982178004818/posts/default/1384957881208845123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192407982178004818/posts/default/1384957881208845123'/><link rel='alternate' type='text/html' href='http://letsfollowtheyellowbrickroad.blogspot.com/2009/03/prototyping-with-pencil-and-powerpoint.html' title='Prototyping with Pencil and Powerpoint'/><author><name>Giorgio Bozio</name><uri>http://www.blogger.com/profile/17360372948342890640</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://4.bp.blogspot.com/_nUoHI0k1B7E/S8oo7PX_iwI/AAAAAAAAAIw/Kzo8gIxoDvY/S220/GB.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192407982178004818.post-7726491468188815040</id><published>2009-02-10T14:10:00.007+01:00</published><updated>2009-07-09T09:00:57.502+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CodeProject'/><title type='text'>Dependency Injection by configuration</title><content type='html'>In an effort to get better at applying the Dependency Injection pattern in my "framework" for data access separation I looked at a way to move out of the code the reference to the assembly and classes that implement the data session interfaces.&lt;br /&gt;&lt;br /&gt;You can read &lt;a href="http://www.codeproject.com/KB/architecture/InMemoryDAL.aspx"&gt;my article at CodeProject&lt;/a&gt; to get the details about the interfaces I use to define data access services. In short, I have a ISession interface that is both an Abstract Factory and a Facade to methods that persist and retrieve objects.&lt;br /&gt;&lt;br /&gt;The pattern is similar to the &lt;a href="http://martinfowler.com/articles/injection.html#UsingAServiceLocator"&gt;Service locator&lt;/a&gt; pattern as defined by Martin Fowler.&lt;br /&gt;&lt;br /&gt;The data access assembly contains classes that implement the ISession interface and the interfaces for data access for the single entities. Instead of referencing this dll directly in my application model assemblies the file location is specified in the app.config file:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;&lt;br /&gt;&amp;lt;configuration&amp;gt;&lt;br /&gt;  &amp;lt;appSettings&amp;gt;&lt;br /&gt;    &amp;lt;add key="DALDllFilePath" &lt;br /&gt; value="C:\PathToTheDalDll\Dal.dll"/&amp;gt;&lt;br /&gt;  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;&amp;lt;/configuration&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Then reflection can be used to load the assembly and instantiate the ISession concrete implementation without adding a reference to the assembly containing it. This approach, though, can be expensive in terms of performance, since instantiating object and calling methods through reflection can be substantially slower then doing it directly in code.&lt;br /&gt;&lt;br /&gt;We can get around performance issues by performing reflection just once by using a singleton object. Doing reflection just in the static constructor ensures that it is done only once at the first reference to the singleton.&lt;br /&gt;&lt;br /&gt;We also need a static method that returns an object implementing the ISession interface.&lt;br /&gt;&lt;br /&gt;So we need to initialize and store in the singleton an instance of a factory object implementing the interface shown below.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public interface ISessionFactory&lt;br /&gt;{&lt;br /&gt; ISession GetSession();&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Having an object implementing this interface in the singleton instance enables us to define a static method that executes GetSession() and returns the ISession concrete implementation to the caller.&lt;br /&gt;&lt;br /&gt;The static constructor will load the assembly located at the path retrieved from the config file, search for a class implementing ISessionFactory, instantiating it and storing it in a private field (sessionFactory). The code will be something like:&lt;br /&gt;&lt;pre&gt;  &lt;br /&gt;internal class sessionDI&lt;br /&gt;{&lt;br /&gt;  private static readonly sessionDI instance = new sessionDI();&lt;br /&gt;  ISessionFactory sessionFactory;&lt;br /&gt;&lt;br /&gt;  static sessionDI()&lt;br /&gt;  {&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  private sessionDI()&lt;br /&gt;  {&lt;br /&gt;     Assembly dalSessionAssembly = Assembly.LoadFile(&lt;br /&gt;       System.Configuration.ConfigurationSettings.AppSettings&lt;br /&gt;                  ["DALDllFilePath"]);&lt;br /&gt;       &lt;br /&gt;      Type[] allTypes = dalSessionAssembly.GetTypes();&lt;br /&gt;       &lt;br /&gt;      foreach (Type type in allTypes)&lt;br /&gt;      {&lt;br /&gt;         if (type.IsClass &amp;amp;&amp;amp; !type.IsAbstract)&lt;br /&gt;         {&lt;br /&gt;            Type iSessionImplementer &lt;br /&gt;                    = type.GetInterface("ISessionFactory");&lt;br /&gt;            if (iSessionImplementer != null)&lt;br /&gt;            {&lt;br /&gt;               this.sessionFactory =&lt;br /&gt;                 dalSessionAssembly.CreateInstance(type.FullName)&lt;br /&gt;                     as ISessionFactory;&lt;br /&gt;            }&lt;br /&gt;         }&lt;br /&gt;      }&lt;br /&gt;      if (this.sessionFactory == null)&lt;br /&gt;              throw new ApplicationException("Configuration error");&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  internal static ISession GetSession()&lt;br /&gt;  {&lt;br /&gt;      return instance.sessionFactory.GetSession();&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The GetSession() singleton static method will simply call the GetSession() method of the sessionFactory object singleton instance loaded at singleton construction.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5192407982178004818-7726491468188815040?l=letsfollowtheyellowbrickroad.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://letsfollowtheyellowbrickroad.blogspot.com/feeds/7726491468188815040/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://letsfollowtheyellowbrickroad.blogspot.com/2009/02/dependency-injection-by-configuration.html#comment-form' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192407982178004818/posts/default/7726491468188815040'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192407982178004818/posts/default/7726491468188815040'/><link rel='alternate' type='text/html' href='http://letsfollowtheyellowbrickroad.blogspot.com/2009/02/dependency-injection-by-configuration.html' title='Dependency Injection by configuration'/><author><name>Giorgio Bozio</name><uri>http://www.blogger.com/profile/17360372948342890640</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://4.bp.blogspot.com/_nUoHI0k1B7E/S8oo7PX_iwI/AAAAAAAAAIw/Kzo8gIxoDvY/S220/GB.jpg'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192407982178004818.post-6406649310361182464</id><published>2009-01-06T21:33:00.003+01:00</published><updated>2009-01-06T21:40:35.567+01:00</updated><title type='text'>Building an Agile SQL Data Access Layer</title><content type='html'>Following my previous article on separating application layers and using an In-memory persistence to "fake" the real data access layer, I've published a new article on implementing the actual data access using the previously outlined architecture and ado.net.&lt;br /&gt;&lt;br /&gt;The article is: &lt;a href="http://www.codeproject.com/KB/architecture/SqlDataAccessLayer.aspx"&gt;Building an Agile SQL Data Access Layer.&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5192407982178004818-6406649310361182464?l=letsfollowtheyellowbrickroad.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://letsfollowtheyellowbrickroad.blogspot.com/feeds/6406649310361182464/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://letsfollowtheyellowbrickroad.blogspot.com/2009/01/building-agile-sql-data-access-layer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192407982178004818/posts/default/6406649310361182464'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192407982178004818/posts/default/6406649310361182464'/><link rel='alternate' type='text/html' href='http://letsfollowtheyellowbrickroad.blogspot.com/2009/01/building-agile-sql-data-access-layer.html' title='Building an Agile SQL Data Access Layer'/><author><name>Giorgio Bozio</name><uri>http://www.blogger.com/profile/17360372948342890640</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://4.bp.blogspot.com/_nUoHI0k1B7E/S8oo7PX_iwI/AAAAAAAAAIw/Kzo8gIxoDvY/S220/GB.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192407982178004818.post-3805795294303496359</id><published>2008-11-21T23:31:00.008+01:00</published><updated>2008-11-26T09:57:30.936+01:00</updated><title type='text'>In memory data access, a methodology to simplify agile development.</title><content type='html'>&lt;span style="font-size:85%;"&gt;[This post is now a &lt;a href="http://www.codeproject.com/KB/architecture/InMemoryDAL.aspx"&gt;CodeProject article&lt;/a&gt;]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Object oriented design concepts and agile development principles state that data access is a detail and not part of the domain of the application model. This means that the architecture of applications should ensure that the implementation of object persistence and retrieval is hidden from the domain of the application model.&lt;br /&gt;&lt;br /&gt;With the complete decoupling of the data access layer comes the possibility to test the business model in isolation by providing a data access layer that mimics a real one but doesn't carry the entire heavy infrastructure needed by a RDBMS and the code to access it.&lt;br /&gt;&lt;br /&gt;A possible way to simulate a data access layer is to use &lt;a href="http://en.wikipedia.org/wiki/Mock_object"&gt;mock objects&lt;/a&gt;. This blog post proposes a slightly different approach that consists of implementing a simple "In memory" data access and persistence mechanism.&lt;br /&gt;&lt;br /&gt;This approach allows deferring the development of the database details, typically involving implementing table structures, sql generation scripts, sql queries and other configurations.&lt;br /&gt;&lt;br /&gt;But how do we obtain complete separation of the data access layer?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:130%;" &gt;Dependency Inversion&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The Dependency Inversion Principle, as Robert C. Martin stated in "Agile Principles, Patterns and Practices in C#" says that:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;High level modules should not depend upon low level modules. Both should depend upon abstractions.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Abstractions should not depend upon details. Details should depend upon abstractions.&lt;/li&gt;&lt;/ul&gt;Dependency inversion separates concerns and enables a top-down developing process, building high level modules before low level modules.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:130%;" &gt;.NET implementation&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Applied to the .net world, dependency inversion implies that:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The DAL (data access layer) should be in a separate assembly.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;The business logic layer and the DAL should depend upon common interfaces defined in a third assembly.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;The DAL shouldn't have the responsibility of instantiating objects, the business logic layer should.&lt;/li&gt;&lt;/ul&gt;This diagram  shows the architecture of this solution for layer separation.&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_nUoHI0k1B7E/SSc3Mpi7gJI/AAAAAAAAAEc/aU_ZBniFeoA/s1600-h/InMemoryDAL1.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 304px;" src="http://3.bp.blogspot.com/_nUoHI0k1B7E/SSc3Mpi7gJI/AAAAAAAAAEc/aU_ZBniFeoA/s320/InMemoryDAL1.png" alt="" id="BLOGGER_PHOTO_ID_5271242579310772370" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;We have 4 assemblies:&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Entities: holds definition for the entities in the application model. It doesn't reference any of the other assemblies.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Logic: contains the application business rules (object creation included). It references Entities and Interfaces.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Interfaces:  contains contracts for low level modules. Data access, in our case. It references Entities.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Data Access: provides services for persisting and retrieving objects. It references Entities and Interfaces.&lt;/li&gt;&lt;/ul&gt;To look at some code I'll use an example application about business order management.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:130%;" &gt;Entities &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here is the class diagram that represents the entities:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_nUoHI0k1B7E/SSc3xac9gKI/AAAAAAAAAEk/WwuinDU6sNs/s1600-h/InMemoryDAL2.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 236px;" src="http://4.bp.blogspot.com/_nUoHI0k1B7E/SSc3xac9gKI/AAAAAAAAAEk/WwuinDU6sNs/s320/InMemoryDAL2.png" alt="" id="BLOGGER_PHOTO_ID_5271243210914365602" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:130%;" &gt;Interfaces&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The separation we are looking for can be obtained by applying abstract factory and facade patterns through the definition of a group of interfaces, one for each entity class, wrapped together by an interface adding connection and transaction management. As in the following class diagram.&lt;p&gt;&lt;/p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_nUoHI0k1B7E/SSc39Y4FIXI/AAAAAAAAAEs/1IO_EDFa9C4/s1600-h/InMemoryDAL3.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 180px;" src="http://4.bp.blogspot.com/_nUoHI0k1B7E/SSc39Y4FIXI/AAAAAAAAAEs/1IO_EDFa9C4/s320/InMemoryDAL3.png" alt="" id="BLOGGER_PHOTO_ID_5271243416649671026" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-style: italic;"&gt;IOrdersSession &lt;/span&gt;interface will orchestrate data access functionality provided by all the single entity data access classes.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public interface IOrdersSession: IDisposable&lt;br /&gt;{&lt;br /&gt;IDbTransaction BeginTransaction();&lt;br /&gt;&lt;br /&gt;ICustomerDAL DbCustomer { get; }&lt;br /&gt;void Save(Customer customer);&lt;br /&gt;void Delete(Customer customer);&lt;br /&gt;&lt;br /&gt;IOrderDAL DbOrder { get; }&lt;br /&gt;void Save(Order order);&lt;br /&gt;void Delete(Order order);&lt;br /&gt;&lt;br /&gt;IOrderItemDAL DbOrderItem { get; }&lt;br /&gt;void Save(OrderItem orderItem);&lt;br /&gt;void Delete(OrderItem orderItem);&lt;br /&gt;&lt;br /&gt;IProductDAL DbProduct { get; }&lt;br /&gt;void Save(Product product);&lt;br /&gt;void Delete(Product product);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This interface derives from &lt;span style="font-style: italic;"&gt;IDisposable &lt;/span&gt;to ensure that any database connection is closed (and transaction rolled back if still present) at object disposal and to enable the use of the using statement.&lt;br /&gt;&lt;br /&gt;This is the code for the &lt;span style="font-style: italic;"&gt;Order &lt;/span&gt;entity data access interface:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;/// method to call to instantiate objects&lt;br /&gt;public delegate Order OrderDataAdapterHandler(&lt;br /&gt;      Guid id, Guid idCustomer, DateTime orderDate);&lt;br /&gt;&lt;br /&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// Order data access interface&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;public interface IOrderDAL&lt;br /&gt;{&lt;br /&gt;List&amp;lt;Order&amp;gt; Search(Guid id, Guid idCustomer,&lt;br /&gt;  DateTime? orderDate,&lt;br /&gt;  OrderDataAdapterHandler orderDataAdapter);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;A callback mechanism is used to instantiate objects off the data access layer. A delegate, &lt;span style="font-style: italic;"&gt;OrderDataAdapterHandler&lt;/span&gt;, is passed as a parameter in the methods that retrieve objects (the search method in our example). A &lt;a href="http://www.dotnetjunkies.com/WebLog/sstewart/archive/2006/08/30/145665.aspx"&gt;blog post&lt;/a&gt; by Scott Stewart is available for detail info about this alternative to using &lt;a href="http://en.wikipedia.org/wiki/Data_Transfer_Object"&gt;DTOs&lt;/a&gt; to retrieve data from the DAL.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:130%;" &gt;Logic&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The business logic classes shouldn't have a direct reference to the DAL classes. Instead, they will reference the &lt;span style="font-style: italic;"&gt;IOrdersSession &lt;/span&gt;interface and a Dependency injection (DI) mechanism will provide the actual object implementing it.&lt;br /&gt;&lt;br /&gt;Dependency injection can be provided by a DI framework (such as NInject or Unity) or, as in the sample code here quoted, by a simple method that instantiates an object implementing &lt;span style="font-style: italic;"&gt;IOrdersSession&lt;/span&gt;. In this case this is done in a conditional way: business logic classes decorated with the &lt;span style="font-style: italic;"&gt;[InMemoryDAL]&lt;/span&gt; attribute will be injected with the InMemory access classes.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;public class InMemoryDALAttribute : System.Attribute { }&lt;br /&gt;&lt;br /&gt;public class GBDipendencyInjection&lt;br /&gt;{&lt;br /&gt;public static IOrderdSession GetSession()&lt;br /&gt;{&lt;br /&gt;// get call stack&lt;br /&gt;StackTrace stackTrace = new StackTrace();&lt;br /&gt;&lt;br /&gt;// get calling class type&lt;br /&gt;Type tipo = stackTrace.GetFrame(1).GetMethod().DeclaringType;&lt;br /&gt;&lt;br /&gt;object[] attributes;&lt;br /&gt;&lt;br /&gt;attributes = tipo.GetCustomAttributes(&lt;br /&gt;                  typeof(InMemoryDALAttribute), false);&lt;br /&gt;&lt;br /&gt;if (attributes.Length == 1)&lt;br /&gt;{&lt;br /&gt;  return new InMemoryOrderSession();&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;  return new SqlServerOrderSession();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Methods that need to retrieve data will instantiate &lt;span style="font-style: italic;"&gt;IOrderSession &lt;/span&gt;in a using statement and pass as a parameter a factory method with a signature corresponding to the one defined in the entity DAL interface.&lt;br /&gt;&lt;pre&gt;public List&amp;lt;Order&amp;gt; GetByCustomerId(Guid customerId)&lt;br /&gt;{&lt;br /&gt;List&amp;lt;Order&amp;gt; lis;&lt;br /&gt;using (IOrdersSession sess&lt;br /&gt;      = GBDipendencyInjection.GetSession())&lt;br /&gt;{&lt;br /&gt;lis = sess.DbOrders.Search(Guid.Empty, customerId, null,&lt;br /&gt;      CreateOrder);&lt;br /&gt;}&lt;br /&gt;return lis;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;In the &lt;span style="font-style: italic;"&gt;OrderLogic &lt;/span&gt;class, &lt;span style="font-style: italic;"&gt;CreateOrder &lt;/span&gt;is the factory method that instantiates objects of type Order.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public Order CreateOrder(Guid id,&lt;br /&gt;                      Guid idCustomer,&lt;br /&gt;                      DateTime orderDate)&lt;br /&gt;{&lt;br /&gt;Order order = new Order();&lt;br /&gt;CustomerLogic costumerLogic = new CustomerLogic();&lt;br /&gt;Customer customer = costumerLogic.GetById(idCustomer);&lt;br /&gt;if (customer == null)&lt;br /&gt;{&lt;br /&gt;throw new ArgumentException("Customer not found.");&lt;br /&gt;}&lt;br /&gt;order.Customer = customer;&lt;br /&gt;order.OrderDate = orderDate;&lt;br /&gt;return order;&lt;br /&gt;}&lt;span style="font-family:Georgia,serif;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:130%;" &gt;In Memory Data Access&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A singleton class contains a generic list of the objects whose storage is simulated. Since it is a singleton, it maintains the list across threads, thus it can be still used when developing the interface (even a web interface) and defer database development in the last stages of development. Cascading Find method is applied to search the list.&lt;br /&gt;&lt;pre&gt;public sealed class OrderInMemoryDAL : IOrderDAL&lt;br /&gt;{&lt;br /&gt;internal List&amp;lt;Order&amp;gt; OrderList;&lt;br /&gt;&lt;br /&gt;static readonly OrderInMemoryDAL _istance&lt;br /&gt;              = new OrderInMemoryDAL();&lt;br /&gt;&lt;br /&gt;private OrderInMemoryDAL()&lt;br /&gt;{&lt;br /&gt;OrderList = new List&amp;lt;Order&amp;gt;();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;internal static OrderInMemoryDAL Istance&lt;br /&gt;{&lt;br /&gt;get { return _istance; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#region IOrderDAL Members&lt;br /&gt;&lt;br /&gt;public List&amp;lt;Order&amp;gt; Search(Guid id, Guid idCustomer,&lt;br /&gt;        DateTime? orderDate, OrderDataAdapterHandler orderDataAdapter)&lt;br /&gt;{&lt;br /&gt;List&amp;lt;Order&amp;gt; lis = OrderList;&lt;br /&gt;&lt;br /&gt;if (id != Guid.Empty)&lt;br /&gt; { lis = lis.FindAll(&lt;br /&gt;    delegate(Order entity) {&lt;br /&gt;           return entity.Id == id; });&lt;br /&gt;          }&lt;br /&gt;if (idCustomer != Guid.Empty)&lt;br /&gt; { lis = lis.FindAll(&lt;br /&gt;    delegate(Order entity) {&lt;br /&gt;           return entity.Costumer.Id == idCustomer; });&lt;br /&gt;          }&lt;br /&gt;if (orderDate.HasValue)&lt;br /&gt; { lis = lis.FindAll(&lt;br /&gt;    delegate(Order entity) {&lt;br /&gt;           return entity.OrderDate == orderDate; });&lt;br /&gt;          }&lt;br /&gt;&lt;br /&gt;return lis;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#endregion&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;span style="font-style: italic;"&gt;InMemoryOrderSession &lt;/span&gt;implements &lt;span style="font-style: italic;"&gt;IOrdersSession &lt;/span&gt;managing saving and deleting simply by adding and removing from the generic lists stored in the singleton objects.&lt;br /&gt;&lt;br /&gt;public class InMemoryOrderSession: IOrdersSession&lt;br /&gt;&lt;pre&gt;{&lt;br /&gt;...&lt;br /&gt;public IOrderDAL DbOrders&lt;br /&gt;{&lt;br /&gt;get { return OrderInMemoryDAL.Istance; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void Save(Order order)&lt;br /&gt;{&lt;br /&gt;Delete(order);&lt;br /&gt;OrderInMemoryDAL.Istance.OrderList.Add(order);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void Delete(Order order)&lt;br /&gt;{&lt;br /&gt;OrderInMemoryDAL.Istance.OrderList.RemoveAll(&lt;br /&gt;  delegate(Order _entity)&lt;br /&gt;     { return _entity.Id == order.Id; }&lt;br /&gt;  );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;This approach enables to develop the model and even the user interface without worrying about the database details. This lowers the cost of changes to the model since it is not required to change database structures and sql scripts and queries.&lt;br /&gt;&lt;br /&gt;Another advantage is being able to test the business logic in isolation from the database access code.&lt;br /&gt;&lt;br /&gt;The last stage of the development of our application will be writing a class implementing &lt;span style="font-style: italic;"&gt;IOrdersSession &lt;/span&gt;that makes use of a RDBMS through an access library, like ADO.NET, providing connection and transaction services.This class will be a facade for all the single classes that manage &lt;a href="http://en.wikipedia.org/wiki/Create,_read,_update_and_delete"&gt;CRUD&lt;/a&gt; operations on the RDBMS for model entities persistence.&lt;br /&gt;&lt;br /&gt;The next step will be removing the &lt;span style="font-style: italic;"&gt;[InMemoryDAL]&lt;/span&gt; attribute from the business logic class. Now the simple DI mechanism will inject the "real" DAL in the application. Running unit tests on the business logic classes again, the DAL will be tested.&lt;br /&gt;&lt;br /&gt;If you're interested to see the sample application you can &lt;a href="http://www.box.net/shared/eyajoi7qoi"&gt;download the file containing the complete Visual Studio solution&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;In next posts I'll focus on the developing of these classes, extending the current sample code and on the CodeSmith templates that can generate much of the glue code necessary for implementing this architecture.&lt;br /&gt;&lt;br /&gt;&lt;img src="http://static.delicious.com/img/delicious.small.gif" alt="Delicious" width="10" height="10" /&gt;&lt;br /&gt;&lt;a href="http://delicious.com/save" onclick="window.open('http://delicious.com/save?v=5&amp;amp;noui&amp;amp;jump=close&amp;amp;url='+encodeURIComponent(location.href)+'&amp;amp;title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550'); return false;"&gt; Bookmark this on Delicious&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fletsfollowtheyellowbrickroad.blogspot.com%2f2008%2f11%2fin-memory-data-access-methodology-to.html"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fletsfollowtheyellowbrickroad.blogspot.com%2f2008%2f11%2fin-memory-data-access-methodology-to.html" alt="kick it on DotNetKicks.com" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5192407982178004818-3805795294303496359?l=letsfollowtheyellowbrickroad.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://letsfollowtheyellowbrickroad.blogspot.com/feeds/3805795294303496359/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://letsfollowtheyellowbrickroad.blogspot.com/2008/11/in-memory-data-access-methodology-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192407982178004818/posts/default/3805795294303496359'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192407982178004818/posts/default/3805795294303496359'/><link rel='alternate' type='text/html' href='http://letsfollowtheyellowbrickroad.blogspot.com/2008/11/in-memory-data-access-methodology-to.html' title='In memory data access, a methodology to simplify agile development.'/><author><name>Giorgio Bozio</name><uri>http://www.blogger.com/profile/17360372948342890640</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://4.bp.blogspot.com/_nUoHI0k1B7E/S8oo7PX_iwI/AAAAAAAAAIw/Kzo8gIxoDvY/S220/GB.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_nUoHI0k1B7E/SSc3Mpi7gJI/AAAAAAAAAEc/aU_ZBniFeoA/s72-c/InMemoryDAL1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192407982178004818.post-305095400075385636</id><published>2008-11-20T12:46:00.001+01:00</published><updated>2010-05-23T15:50:13.921+02:00</updated><title type='text'>Follow the Yellow Brick Road</title><content type='html'>&lt;object style="background-image:url(http://i3.ytimg.com/vi/66sQF1jfEMk/hqdefault.jpg)"  width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/66sQF1jfEMk&amp;amp;hl=it_IT&amp;amp;fs=1"&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;embed src="http://www.youtube.com/v/66sQF1jfEMk&amp;amp;hl=it_IT&amp;amp;fs=1" width="425" height="344" allowScriptAccess="never" allowFullScreen="true" wmode="transparent" type="application/x-shockwave-flash"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;Follow the yellow brick road, follow the yellow brick road&lt;br /&gt;Follow, folllow, follow, follow, follow the yellow-brick road&lt;br /&gt;Follow the yellow-brick, follow the yellow-brick&lt;br /&gt;Follow the yellow-brick road&lt;br /&gt;&lt;br /&gt;You're off to see the Wizard, the Wonderful Wizard of Oz&lt;br /&gt;You'll find he is a Whiz of a Wiz if ever a Wiz there was&lt;br /&gt;If ever, oh ever, a Wiz there was the Wizard of Oz is one because&lt;br /&gt;Because, because, because, because, because&lt;br /&gt;Because of the wonderful things he does&lt;br /&gt;You're off the see the wizard, the Wonderful Wizard of Oz&lt;br /&gt;&lt;br /&gt;... Just to explain the blog title ...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5192407982178004818-305095400075385636?l=letsfollowtheyellowbrickroad.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://letsfollowtheyellowbrickroad.blogspot.com/feeds/305095400075385636/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://letsfollowtheyellowbrickroad.blogspot.com/2008/11/follow-yellow-brick-road.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192407982178004818/posts/default/305095400075385636'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192407982178004818/posts/default/305095400075385636'/><link rel='alternate' type='text/html' href='http://letsfollowtheyellowbrickroad.blogspot.com/2008/11/follow-yellow-brick-road.html' title='Follow the Yellow Brick Road'/><author><name>Giorgio Bozio</name><uri>http://www.blogger.com/profile/17360372948342890640</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://4.bp.blogspot.com/_nUoHI0k1B7E/S8oo7PX_iwI/AAAAAAAAAIw/Kzo8gIxoDvY/S220/GB.jpg'/></author><thr:total>0</thr:total></entry></feed>
