<?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>Gabriel Schenker&#039;s Blog</title>
	<atom:link href="http://lostechies.com/gabrielschenker/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/gabrielschenker</link>
	<description>Blog about architectural patterns, best practices, coding principles and techniques</description>
	<lastBuildDate>Mon, 12 Dec 2011 14:07:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Win Free Copies of NHibernate 3 Beginner&#8217;s Guide</title>
		<link>http://lostechies.com/gabrielschenker/2011/12/12/win-free-copies-of-nhibernate-3-beginners-guide/</link>
		<comments>http://lostechies.com/gabrielschenker/2011/12/12/win-free-copies-of-nhibernate-3-beginners-guide/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 14:07:31 +0000</pubDate>
		<dc:creator>Gabriel Schenker</dc:creator>
				<category><![CDATA[book]]></category>
		<category><![CDATA[Fluent NHibernate]]></category>
		<category><![CDATA[misc]]></category>
		<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://lostechies.com/gabrielschenker/2011/12/12/win-free-copies-of-nhibernate-3-beginners-guide/</guid>
		<description><![CDATA[Readers would be pleased to know that I have teamed up with Packt Publishing and we are organizing a Giveaway especially for you and three lucky winners stand a chance to win a copy of Keep reading to find out&#160;&#8230; <a href="http://lostechies.com/gabrielschenker/2011/12/12/win-free-copies-of-nhibernate-3-beginners-guide/">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Readers would be pleased to know that I have teamed up with Packt Publishing and we are organizing a Giveaway especially for you and three lucky winners stand a chance to win a copy of Keep reading to find out how you can be one of the Lucky Winner.<br />
<h3>Overview of Nhibernate 3 Beginner&#8217;s Guide</h3>
<p><a href="http://lostechies.com/gabrielschenker/files/2011/12/clip_image002.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 24px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://lostechies.com/gabrielschenker/files/2011/12/clip_image002_thumb.jpg" width="227" height="244"></a>
<p>· Clear, precise step-by-step directions to get you up and running quickly
<p>· Test, profile, and monitor data access to tune the performance and make your applications fly
<p>· Reduce hours of application development time and get better application architecture and performance
<p>Read more about this book and download free <a href="http://www.packtpub.com/sites/default/files/6020OS-Chapter-3-Creating-a-%20Model.pdf?utm_source=packtpub&amp;utm_medium=free&amp;utm_campaign=pdf">Sample Chapter</a><b></b>
<p><b>How to Enter?</b>
<p>All you need to do is head on over to the <a href="http://www.packtpub.com/nhibernate-3-beginners-guide/book">book page</a> and look through the product description of this book and drop a line via the <b>comments below to let us know what interests you the most about this book</b>. It’s that simple
<p>Product description for NHibernate book: http://www.packtpub.com/nhibernate-3-beginners-guide/book
<p>Winners from the U.S. and Europe can either choose a physical copy of the book or the eBook. Users from other locales are limited to the eBook only.
<p><strong>Deadline</strong>
<p><strong><br /></strong><b>The contest will close on 30/12/11 PT. Winners will be contacted by email, so be sure to use your real email address when you comment!</b></p>
]]></content:encoded>
			<wfw:commentRss>http://lostechies.com/gabrielschenker/2011/12/12/win-free-copies-of-nhibernate-3-beginners-guide/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>BUILD conference&#8211;day 3</title>
		<link>http://lostechies.com/gabrielschenker/2011/09/16/build-conferenceday-3/</link>
		<comments>http://lostechies.com/gabrielschenker/2011/09/16/build-conferenceday-3/#comments</comments>
		<pubDate>Fri, 16 Sep 2011 15:58:27 +0000</pubDate>
		<dc:creator>Gabriel Schenker</dc:creator>
				<category><![CDATA[BUILD]]></category>
		<category><![CDATA[Conference]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://lostechies.com/gabrielschenker/2011/09/16/build-conferenceday-3/</guid>
		<description><![CDATA[The future of C# Yesterday Anders Hejlsberg gave a talk about future directions of C# and VB.Net. He started with look back and then immediately dive into the new features of C# 5.0 which is part of VS 2011 and&#160;&#8230; <a href="http://lostechies.com/gabrielschenker/2011/09/16/build-conferenceday-3/">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>The future of C#</h2>
<p>Yesterday Anders Hejlsberg gave a talk about future directions of C# and VB.Net. He started with look back and then immediately dive into the new features of C# 5.0 which is part of VS 2011 and .NET 4.5. The most prominent new feature is of course the direct language support for asynchronous programming. The compiler provides two new keywords <strong>async</strong> and <strong>await</strong> which doesn’t sound exciting at all but in reality dramatically simplifies the way we developers can write “fast and fluid” code. Instead of dealing with threads, thread synchronization and callback functions ourselves we can now write fully asynchronous code in a sequential way. The compiler will do the heavy lifting for us and convert this “sequential and seemingly synchronous” code into a sequence of asynchronous calls and their corresponding continuations.</p>
<p>If you think that this is not worth talking about then try to write a sequence of asynchronous calls that depend on each other. And make sure that you provide adequate exception handling.</p>
<p>During his presentation Anders Hejlsberg also revealed some details about the future version of C# and he announced that a first developer preview will be available in about 4 weeks. The main part of the upcoming version of C# is a completely new compiler which is written in C# and can be used as a service. The project has the code name Rosalyn.</p>
<p>This “compiler as a service” will be of tremendous value for various scenarios. All kinds of tools, utilities or plugins will be able the leverage the compilers capabilities to their favor. Some samples are</p>
<ul>
<li>Intellisense, code coloring will leverage the output of the parser part of the compiler
<li>Refactoring tools like Resharper do not have to provide their own parser any more and can leverage the compiler
<li>Compile and execute scripts or code snippets (provided e.g. as string) on the fly
<li>Future versions of Visual Studio will leverage the compiler and provide an interactive console for C#
<li>Automatically translating code from one language to another; Anders demoed the translation from C# to VB.NET and vice versa
<li>Meta programming a la Boo or Ruby will be possible
<li>etc.</li>
</ul>
<p>I think this new compiler will once again dramatically improve the development experience with C# (and VB.NET). </p>
<h2>The new XAML editor in VS 2011</h2>
<p>If you have worked with WPF or Silverlight in Visual Studio 2010 or 2008 you know that the XAML editor was extremely slow and limited in its functionality. Now that has changed dramatically in VS 2011. First of all the new XAML editor is backed by the same engine (or at least part of it) as Expression Blend. The editor now runs in its own process to not compromise the stability and availability of VS. The editing capabilities have tremendously improved and members of the VS team&nbsp; confirmed me that they are tuning the editor as much as possible and make it performing well also in very large project with many assets.</p>
<h2>Expression Blend for HTML5/CSS applications</h2>
<p>Expression Blend is now available in a new flavor. HTML5/CSS3 based Metro style applications can now be visually designed in Blend. Many of the new CSS3 features are fully supported by this new editor. Not only is Expression Blend a layout tool but it fully supports the interactive mode (that is JavaScript is executed) which is very important in scenarios where most of the page is rendered dynamically, driven by JavaScript. </p>
]]></content:encoded>
			<wfw:commentRss>http://lostechies.com/gabrielschenker/2011/09/16/build-conferenceday-3/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>BUILD conference&#8211;day 2</title>
		<link>http://lostechies.com/gabrielschenker/2011/09/14/build-conferenceday-2/</link>
		<comments>http://lostechies.com/gabrielschenker/2011/09/14/build-conferenceday-2/#comments</comments>
		<pubDate>Thu, 15 Sep 2011 05:42:55 +0000</pubDate>
		<dc:creator>Gabriel Schenker</dc:creator>
				<category><![CDATA[BUILD]]></category>
		<category><![CDATA[Conference]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://lostechies.com/gabrielschenker/2011/09/14/build-conferenceday-2/</guid>
		<description><![CDATA[Today was the day of Windows 8 Server and of the Windows runtime (WinRT). WinRT is the new layer providing a language neutral interface to the underlying operating system. It is written in C++ and consists of purely native code.&#160;&#8230; <a href="http://lostechies.com/gabrielschenker/2011/09/14/build-conferenceday-2/">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today was the day of Windows 8 Server and of the Windows runtime (WinRT).</p>
<p>WinRT is the new layer providing a language neutral interface to the underlying operating system. It is written in C++ and consists of purely native code. For me it seems to be the revival of the dinosaurs since WinRT basically is a collection of COM objects. Hello <strong>IUnknown</strong>, nice to meet you again!</p>
<p>C++ developers must feel like in paradise. This old language celebrates a true revival during this conference and with the advent of Windows 8. It seems awkward to me that a language that is not really object oriented in its roots, still can play such an important role. I ask myself why did the project “<a href="http://research.microsoft.com/en-us/projects/singularity/">Singularity</a>” of Microsoft, which had (amongst others) the goal to create an OS which consists purely of managed code &#8211; except for a very very limited set of low level functionality, which had to be implemented in native code &#8211; not drive Microsoft towards a more managed Windows OS. Why do we still need to rely on COM which is a very old and outdated concept?</p>
<p>On the positive side we can acknowledge that WinRT provides meta information in the same format as the .NET type meta information. As a consequence this API can be accessed from C#, VB.NET and JavaScript in a very natural way. To an e.g. C# developer components of WinRT look 100% alike true managed objects. The availability of this meta data allows Visual Studio to provide true intellisense for all of these components.</p>
<p>Another positive aspect of WinRT is that all functions that take more than 15 milliseconds are now executed asynchronously. This helps to achieve the goal to make all Metro type applications execute “fast an fluid”. From C# (and .NET 4.5) it is very easy to access such asynchronous functions since the compiler provides the concept of <strong>async</strong> and <strong>await</strong>. With these two new keywords we can write fully asynchronous code in a way as if everything was sequential.</p>
<p>JavaScript introduces the concept of <strong>promises</strong> to deal with asynchronous calls. This concept makes it very easy to create applications that remain responsive even if long running functions are called. </p>
<p>There is one positive change that the Windows team did to COM to avoid unnecessary race conditions when calling asynchronous functions of WinRT. In Windows 8 no method of a COM object is executed as long any other method of the same instance is still pending. Sweet!</p>
]]></content:encoded>
			<wfw:commentRss>http://lostechies.com/gabrielschenker/2011/09/14/build-conferenceday-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>BUILD conference&#8211;day 1</title>
		<link>http://lostechies.com/gabrielschenker/2011/09/13/build-conferenceday-1/</link>
		<comments>http://lostechies.com/gabrielschenker/2011/09/13/build-conferenceday-1/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 03:33:55 +0000</pubDate>
		<dc:creator>Gabriel Schenker</dc:creator>
				<category><![CDATA[Conference]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://lostechies.com/gabrielschenker/2011/09/13/build-conferenceday-1/</guid>
		<description><![CDATA[Day one is over and my head is packed with new information and impressions. It was a heavy dose of new stuff that was presented to us. But I have to admit, for the first time since many years I&#160;&#8230; <a href="http://lostechies.com/gabrielschenker/2011/09/13/build-conferenceday-1/">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://lostechies.com/gabrielschenker/files/2011/09/Slate-PC-Samsung-700T1A-Serie-7.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 5px 24px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="Slate PC Samsung 700T1A Serie 7" border="0" alt="Slate PC Samsung 700T1A Serie 7" align="left" src="http://lostechies.com/gabrielschenker/files/2011/09/Slate-PC-Samsung-700T1A-Serie-7_thumb.jpg" width="244" height="191"></a>Day one is over and my head is packed with new information and impressions. It was a heavy dose of new stuff that was presented to us. But I have to admit, for the first time since many years I feel excited about what I saw and what I heard. And believe me, it’s not only because of the nice Samsung 700T1A tablet PC we got with pre-installed Windows 8, no it’s because of Windows 8 itself.</p>
<p>Windows 8 will run everywhere on big servers sitting in the data center as well as on the small gadget we carry around all day with us. this makes it much easier for us developer to come up with applications that run on a huge array of different devices having different form factors.</p>
<p>Windows 8 will continue to support all applications that currently run on Windows 7. These applications will act and feel exactly the same way as they currently do on Windows 7. But then there will be the new Metro style applications which are unique to Windows 8 (and thus will not run on any older version of Windows). </p>
<p>The new type of applications can be developed either in a managed language like C# or VB using XAML as the layout “language” or in JavaScript using HTML5 and CSS as the layout language. Even C++ can be used in conjunction with XAML to produce native Metro applications.</p>
<p>Microsoft has completely rewritten the XAML stack and based it fully on DirectX. Yes, that is amazing, not only will XAML be supported in the future but it has been radically improved.</p>
<p>Expression Blend 5 can now be used to edit XAML templates as well as HTML templates. That was another nice thing to hear since Blend is a really powerful and cool tool to do UI design. Expression Blend and Visual Studio work hand in hand.</p>
<p>The new Windows 8 Metro interface actually makes a lot of sense. One of its key paradigms is “content over chrome”, which means that we developer should more focus on presenting content to the user than unnecessary clutter around it. Windows 8 will also make sure that in the future any screen is a multi-touch surface. Using our fingers will become another natural way of doing things on a computer as it is already the case with keyboards and mice. Yes, keyboards and mice will not be replaced. There is no better tool to enter large amounts of text than a keyboard and there is hardly a better device than a mouse (or track ball) to precisely position or move things on the screen. On the other hand there are many areas where it just feels more natural and direct to use our fingers than the keyboard or mouse. If you use a smart phone with a big touch screen then you know what I’m talking about.</p>
<p><a href="http://lostechies.com/gabrielschenker/files/2011/09/Windows8.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 15px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="Windows8" border="0" alt="Windows8" align="right" src="http://lostechies.com/gabrielschenker/files/2011/09/Windows8_thumb.jpg" width="473" height="266"></a>All Metro type applications will sit on top of the new WinRT API. This API provides the applications access to the underlying system. It is possible to access the file system or network resources as well as devices in an easy and straight forward manner. We can e.g. create a Web application and write JavaScript code which accesses, to give a sample, the camera of the device it is running on and take the pictures and movies produced by this camera and save them on the local hard disk. But wait, isn’t that dangerous? Luckily the security system will prevent the application in doing so without the users explicit consent.</p>
<p>I am very pleased to hear that maximizing the performance of the system while minimizing the required resources was one of the main goals while developing Windows 8. We have seen numerous samples how Windows 8 performed better than Windows 7 on the same hardware.</p>
<p>I am looking forward to day 2 presenting us much more in depth information about various areas of this new version of Windows.</p>
]]></content:encoded>
			<wfw:commentRss>http://lostechies.com/gabrielschenker/2011/09/13/build-conferenceday-1/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>BUILD conference&#8211;day 0</title>
		<link>http://lostechies.com/gabrielschenker/2011/09/13/build-conferenceday-0/</link>
		<comments>http://lostechies.com/gabrielschenker/2011/09/13/build-conferenceday-0/#comments</comments>
		<pubDate>Tue, 13 Sep 2011 13:54:36 +0000</pubDate>
		<dc:creator>Gabriel Schenker</dc:creator>
				<category><![CDATA[Conference]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://lostechies.com/gabrielschenker/2011/09/13/build-conferenceday-0/</guid>
		<description><![CDATA[I am here in Anaheim CA attending the Microsoft BUILD conference. During the next 4 days Microsoft will finally reveal details about the upcoming Windows 8. The sparse information that has been available so far left us developers and architects&#160;&#8230; <a href="http://lostechies.com/gabrielschenker/2011/09/13/build-conferenceday-0/">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I am here in Anaheim CA attending the Microsoft BUILD conference. During the next 4 days Microsoft will finally reveal details about the upcoming Windows 8. The sparse information that has been available so far left us developers and architects in doubt about the future strategy of Microsoft regarding software development.</p>
<p>Quite some years ago our company chose Silverlight as the platform for the user interface of our application suite. During all this time Microsoft has assured its clients that Silverlight is one of their strategic platforms. New releases of Silverlight have been publish in short intervals. Currently version 5 is available as release candidate. Silverlight was used exclusively on Windows phone 7 and was meant to be the ubiquitous platform on all future mobile devices produced and/or supported by Microsoft. As a side note: you might remember that Windows Mobile 6.5 is a dead end and is not developed an further.</p>
<p>A couple of month ago Microsoft publicly announced that Windows 8 will deeply integrate HTM5, Java Script and CSS into the platform. They also announced that HTML5 will be the main development platform on Windows and that Windows 8 will run everywhere, on servers, workstations, tablet devices , phones and embedded systems. No word about Silverlight though… </p>
<p>All our questions regarding the future of Silverlight were left unanswered.</p>
<p>Ok, today and during the coming days we will hopefully get some more insight into the future strategies of Microsoft. This will be interesting.</p>
]]></content:encoded>
			<wfw:commentRss>http://lostechies.com/gabrielschenker/2011/09/13/build-conferenceday-0/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to map a domain model with NHibernate?</title>
		<link>http://lostechies.com/gabrielschenker/2011/09/02/how-to-map-a-domain-model-with-nhibernate/</link>
		<comments>http://lostechies.com/gabrielschenker/2011/09/02/how-to-map-a-domain-model-with-nhibernate/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 04:06:00 +0000</pubDate>
		<dc:creator>Gabriel Schenker</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://lostechies.com/gabrielschenker/2011/09/02/how-to-map-a-domain-model-with-nhibernate/</guid>
		<description><![CDATA[Today a friend of mine ask me the following (I am para-phrasing): “I have a question regarding NHibernate and mapping. In an application we want to access the database through NHibernate from inside a WCF service, thus lazy loading is&#160;&#8230; <a href="http://lostechies.com/gabrielschenker/2011/09/02/how-to-map-a-domain-model-with-nhibernate/">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today a friend of mine ask me the following (I am para-phrasing): </p>
<blockquote><p><em>“I have a question regarding NHibernate and mapping. In an application we want to access the database through NHibernate from inside a WCF service, thus lazy loading is not an option for us.&nbsp; To avoid to have to use the whole graph around an entity each time I want to use two domain models. The first model contains all entities without associations and the second one the model with all associations between the entities.</em></p>
<p><em>Is this the usual approach people chose when dealing with similar problems? Are there any problems to be expected if two different entities are mapped to the same table?”</em></p>
</blockquote>
<p>Now, let me try to answer this question(s). First of all let’s try to clarify what thoughts might be behind those questions.</p>
<ol>
<li>If we turn <strong>off</strong> lazy loading in NHibernate and have a domain model where (almost) all entities are connected to each other through relations then we have a problem when loading telling NHibernate to load one of the entities of the domain model. Since lazy loading is turned off NHibernate would not only load the entity itself but all other entities that are related to the entity to be loaded. In an extreme case one would cause the whole database to be loaded.
<li>We can “kind of” solve this problem if we break the chain of relations in the model. In the extreme case we have a (degenerated) domain model with entities that are not related to each other.
<li>But if we only have a bunch of entities in our model that are not related to each other then we cannot easily navigate from one entity to another and thus using the domain for querying becomes unhandy if not impossible since when querying data to display on screen or in a report we most certainly need more data then the one that is stored in a single entity (e.g. when displaying the details of a product on screen we also want to display the categories the product is associated with as well as a photo of the product and maybe even related products.).</li>
</ol>
<p>Now, what is the correct answer?</p>
<p>As always I have to say: “It depends!” There is no good answer which fits any situation. That said, let’s try to give some possible guidelines for different scenarios</p>
<h2>Scenario 1: Relatively simple forms over data type application</h2>
<p>In this scenario we should keep things as simple as possible. We want to define only one model of the domain at hand and we want to use this model for data manipulation as well as for query operations. In this case I would recommend to use lazy loading of NHibernate (or any other ORM). All entities of the model are interconnected through relations. As a simple sample lets take the blog sample.</p>
<p><a href="http://lostechies.com/gabrielschenker/files/2011/09/image.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lostechies.com/gabrielschenker/files/2011/09/image_thumb.png" width="475" height="418"></a></p>
<h3>Commands – that is writing data</h3>
<p>Now when we want to manipulate data we can have different scenarios</p>
<ol>
<li>Manipulating the blog entity
<ul>
<li>create a new blog.
<li>update an existing blog and change its title, add another author or add some more categories. etc.
<li>delete the blog (with all its posts)</li>
</ul>
<li>Authoring posts
<ul>
<li>write a new post.
<li>edit a post to modify the content or add tags
<li>delete a post.</li>
</ul>
<li>Commenting a post
<ul>
<li>reader adds a new comment to a blog post</li>
</ul>
</li>
</ol>
<p>Each of the above operations is very limited in its extent. When manipulating the blog entity I am not interested in the post that were written as part of this blog and certainly I am not interested in the comments to each post. Thus I do not need to load any post or comment data. Since the relations from the blog entity to the posts are mapped as lazy I can load the blog entity without any side effects. Only the blog data is loaded and no other entity is populated by this operation</p>
<blockquote><p><font face="Courier New">var blog = session.Get&lt;Blog&gt;(1);</font></p>
</blockquote>
<p>Specifically NHibernate does not populate the <strong>Authors</strong> nor the <strong>Categories</strong> collection of the blog entity</p>
<p>On the other hand when authoring a new post I am not really interested in the details of the blog to which the post is associated. The only things I need to know when creating a new post are a) the content of the post, b) the key (ID) of the blog to which the post is associated and c) the collection of tags under which the post shall be classified. The code might then look like this:</p>
<blockquote><p><font face="Courier New">var post = new Post{ Content = dto.Content };</font></p>
<p><font face="Courier New">post.Blog = session.Load&lt;Blog&gt;(dto.BlogId);</font></p>
<p><font face="Courier New">foreach(var tag in dto.Tags) {</font></p>
<p><font face="Courier New">&nbsp;&nbsp;&nbsp; post.AddTag(tag);</font></p>
<p><font face="Courier New">}</font></p>
<p><font face="Courier New">session.Save(post);</font></p>
</blockquote>
<p>Here dto is the data transfer object that contains the data coming from the client. </p>
<p>Please not the <font face="Courier New">session.Load&lt;Blog&gt;(…)</font> operation. This operation does not load any data from the database. It just creates a proxy of the blog entity in memory and populates the ID with the value provided, that is dto.BlogId. That’s enough for NHibernate to successfully make an association between the post and the blog.</p>
<p>If we update an existing post we can load it like this</p>
<blockquote><p><font face="Courier New">var post = session.Load&lt;Post&gt;(postId);</font></p>
</blockquote>
<p>Since we have lazy loading turned on no associated entities will be loaded and I can happily update my post entity.</p>
<h3>Queries – reading data</h3>
<p>When reading data to display on screen or in a report the situation is a little bit different. Now all of a sudden I need the relations between the entities to not only load an entity but also associated information stored in related entities. Samples:</p>
<ol>
<li>Display blog details and a list of titles of the 10 most recent posts
<li>Display the content of a post and all its associated comments
<li>Display a list of the most popular blog posts of the last year
<li>etc.</li>
</ol>
<p>How can we do that in knowing that we have NHibernate lazy loading turned on? And how can we do it efficiently and avoid such things as the infamous select-(n+1) problem? And please do not forget that we are querying the database from within a WCF service and thus need to make sure that all data has been loaded at the moment the (NHibernate) session is disposed.</p>
<p>The answer is: use eager loading! Whether we use HQL, Criteria Queries or LINQ to retrieve the data, we always have the possibility to instruct NHibernate to eagerly load some associated data. Let’s give a sample: I want to load the details of a post and all its associated comments. Using LINQ the query would look similar to this:</p>
<blockquote><p><font face="Courier New">var post = session.Query&lt;Post&gt;</font></p>
<p><font face="Courier New">&nbsp;&nbsp;&nbsp; .Fetch(p =&gt; p.Comments)</font></p>
<p><font face="Courier New">&nbsp;&nbsp;&nbsp; .Single(p =&gt; p.PostId = 101);</font></p>
</blockquote>
<p>Note the Fetch function which instructs LINQ to load the collection of comments with the post.</p>
<p>Although the relation between Post and Comment is mapped as lazy we were able to load post and comments in one go. Nice.</p>
<h2>Scenario 2: Complex domain with many complicated business rules</h2>
<p>This is a completely different situation than the previous one. Here we are probably talking about an enterprise application where we can justify some “overhead” if it helps us to decrease or manage the complexity of the overall system.</p>
<p>In such a scenario I would highly recommend to use an architectural pattern known as CQRS (command query responsibility segregation). In this pattern data manipulation (commands) and data retrieval (query) operations are strictly separated. The commands operate on a domain model whereas the queries do NOT use the domain model but are sent as directly as possible to the database. Having this separation of concerns helps us to reduce the complexity of the domain. The domain is now not responsible to satisfy query request but can be fully optimized for data manipulation (i.e. business transaction).</p>
<p>The domain model is carefully segregated into aggregates which represent the boundaries of a typical business transaction. Inside an aggregate entities are associated to each other through relations. Any associations to entities which are not part of the aggregate are achieved by using (foreign-) keys.</p>
<p>Having defined these aggregates we do not need to use lazy loading since we always want to load the whole aggregate when operation on (part of) it.</p>
<p>For the queries we don’t even necessarily need NHibernate to access the database but can use a thin data layer and ADO.NET to get to the required data.</p>
<p>The data we want to read can be provided by various means. Each has its advantages and disadvantages</p>
<ul>
<li>The application uses two databases. One for the write operations and the other one for the read operations. The read only database contains the de-normalized data of the write-only database (the two databases are synchronized through some services). One can think of this read-only database as being kind of a data warehouse.
<li>The application only uses one database for writing and reading. We access the data through database views which provide a de-normalized view of the data which is optimized for read operations.
<li>Here also we use only one database. Dynamic SQL is used to retrieve the data&nbsp; </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://lostechies.com/gabrielschenker/2011/09/02/how-to-map-a-domain-model-with-nhibernate/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>NHibernate 3 Beginners Guide published</title>
		<link>http://lostechies.com/gabrielschenker/2011/08/29/nhibernate-3-beginners-guide-published/</link>
		<comments>http://lostechies.com/gabrielschenker/2011/08/29/nhibernate-3-beginners-guide-published/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 01:56:52 +0000</pubDate>
		<dc:creator>Gabriel Schenker</dc:creator>
				<category><![CDATA[book]]></category>
		<category><![CDATA[introduction]]></category>
		<category><![CDATA[NHibernate]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://lostechies.com/gabrielschenker/2011/08/29/nhibernate-3-beginners-guide-published/</guid>
		<description><![CDATA[I am very pleased to announce that my book NHibernate 3 Beginners Guide has finally been published. It is a wonderful feeling to finally have a book in my hands that cost me a couple of months of intense work.&#160;&#8230; <a href="http://lostechies.com/gabrielschenker/2011/08/29/nhibernate-3-beginners-guide-published/">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://lostechies.com/gabrielschenker/files/2011/08/image.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: left; padding-top: 0px; border: 0px;" title="image" src="http://lostechies.com/gabrielschenker/files/2011/08/image_thumb.png" border="0" alt="image" width="198" height="244" align="left" /></a></p>
<p>I am very pleased to announce that my book <a href="http://www.packtpub.com/nhibernate-3-beginners-guide/book">NHibernate 3 Beginners Guide</a> has finally been published. It is a wonderful feeling to finally have a book in my hands that cost me a couple of months of intense work. But I think the result is well worth it.</p>
<p>If you are interested in the book then there is also a <a href="http://www.packtpub.com/sites/default/files/6020OS-Chapter-3-Creating-a-%20Model.pdf?utm_source=packtpub&amp;utm_medium=free&amp;utm_campaign=pdf">free chapter</a> available for download.</p>
<p>I was lucky to have <a href="http://fabiomaulo.blogspot.com/">Fabio Maulo</a> and <a href="http://joseoncode.com/">José F. Romaniello</a> as my reviewer, the former being the lead of the <a href="http://www.nhforge.org">NHibernate</a> project and the latter an active contributor to the the project.</p>
<p>My goal for this book has been to provide an easy to follow introduction to NHibernate 3.x. The text covers NHibernate up to version 3.1 GA and even references some of the new features of NHibernate 3.2 GA. It was very important to me to not use a data centric approach but rather choose a <strong>model first</strong> approach.</p>
<p>In this regard this book is NOT just an updated version of <a href="https://www.packtpub.com/nhibernate-2-beginners-guide/book">NHibernate 2 Beginners Guide</a> but rather a complete rewrite.</p>
<p>I also have paid attention to cover all foundational topics in a clear and concise way. In no way did I want to abandon the reader in the dust of uncertainty.</p>
<p>Let me provide you the list of chapters found in the book with a short introduction about the respective content of each chapter.</p>
<p><strong>Chapter 1, First Look…</strong> explains what NHibernate is and why we would use it in an application that needs to access data in a relational database. The chapter also briefly presents what is new in NHibernate 3.x compared to the version 2.x and discusses how one can get this framework. Links to various sources providing documentation and help are presented.</p>
<p><strong>Chapter 2, A First Complete Sample…</strong>walks through a simple yet complete sample where the core concepts of NHibernate and its usage are introduced.</p>
<p><strong>Chapter 3, Creating a Model…</strong> discusses what a domain model is and what building blocks constitute such a model. In an exercise the reader creates a domain model for a simple ordering system.</p>
<p><strong>Chapter 4, Defining the Database Schema…</strong>explains what a database schema is and describes in details the individual parts comprising such a schema. A schema for the ordering system is created in an exercise.</p>
<p><strong>Chapter 5, Mapping the Model to the Database…</strong>teaches how to bridge the gap between the domain model and the database schema with the aid of some wiring. This chapter presents four distinct techniques how the model can be mapped to the underlying database or vice versa. It is also shown how we can use NHibernate to automatically create the database schema by leveraging the meta-information contained in the domain model.</p>
<p><strong>Chapter 6, Sessions and Transactions…</strong>teaches how to create NHibernate sessions to communicate with the database and how to use transactions to group multiple tasks into one consistent operation which succeeds or fails as a whole.</p>
<p><strong>Chapter 7, Testing, Profiling, Monitoring and Logging…</strong>introduces how to test and profile our system during development to make sure we deliver a reliable, robust and maintainable application. It also shows how an application can be monitored in a productive environment and how it can log any unexpected or faulty behavior.</p>
<p><strong>Chapter 8, Configuration… </strong>explains how we can tell NHibernate which database to use, as well as provide it the necessary credentials to get access to the stored data. In addition to that many more settings for NHibernate to tweak and optimize the database access are explained in this chapter.</p>
<p><strong>Chapter 9, Writing Queries…</strong> discusses the various means how we can easily and efficiently query data from the database to create meaningful reports on screen or on paper.</p>
<p><strong>Chapter 10, Validating the data to persist…</strong>discusses why data collected by an application needs to be correct, complete and consistent. It shows how we can instrument NHibernate to achieve this goal through various validation techniques.</p>
<p><strong>Chapter 11, Common Pitfalls – Things to avoid…</strong> as the last chapter of this book presents the most common errors developers can make when using NHibernate to write or read data to and from the database. Each such pitfall is discussed in details and possible solutions to overcome the problems are shown.</p>
]]></content:encoded>
			<wfw:commentRss>http://lostechies.com/gabrielschenker/2011/08/29/nhibernate-3-beginners-guide-published/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Ranting about the quality of developers</title>
		<link>http://lostechies.com/gabrielschenker/2011/01/18/ranting-about-the-quality-of-developers/</link>
		<comments>http://lostechies.com/gabrielschenker/2011/01/18/ranting-about-the-quality-of-developers/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 05:01:48 +0000</pubDate>
		<dc:creator>Gabriel Schenker</dc:creator>
				<category><![CDATA[hiring]]></category>
		<category><![CDATA[misc]]></category>

		<guid isPermaLink="false">/blogs/gabrielschenker/archive/2011/01/18/ranting-about-the-quality-of-developers.aspx</guid>
		<description><![CDATA[I am in the happy position that I work for a company who is steadily growing. As a consequence we were and are hiring new developers. I had and have the “pleasure” to be part of this hiring process. I&#160;&#8230; <a href="http://lostechies.com/gabrielschenker/2011/01/18/ranting-about-the-quality-of-developers/">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I am in the happy position that I work for a company who is steadily growing. As a consequence we were and are hiring new developers. I had and have the “pleasure” to be part of this hiring process. I put the word “pleasure” in double quotes since often times it was more a sad than a pleasant experience. </p>
<p>First of all I have to admit that we failed completely when searching candidates ourselves by announcing open positions in blog post, on our company’s web site or when placing ads in various well known lists. Not only did we get low quality applications, no, we got near to zero response. Thus we hired some head hunters; not only one, but four of them. Finally we got some CVs from potential candidates. With the candidates that had interesting enough resumeés we arranged phone interviews. During these phone calls we give the candidates the opportunity to tell us where they think they are best at and what they are looking for. Although we do not ask very specific and certainly not very difficult questions, a lot of candidates have big troubles in coming up with some “meaningful” or “relevant” answers. Most of the candidates just fail on this first hurdle. Some interesting sample questions and answers: </p>
<ul>
<li>We might ask the candidate something like: “Please tell us what principles or practices you use in your daily work to create robust, maintainable and/or extendable code.” One candidate, after asking us to repeat the question, said: “I am sorry, I cannot answer this question, but can you give me an answer?” Our answer then was rather clear: “I am sorry, but we are looking for candidates who know an answer to this question…”</li>
<li>To another candidate we said: “On a scale of 1 to 10, where would position yourself regarding your skills in C#?”. The candidate answered without hesitating: “I think I would give myself a 9.5.” Ha, you can imagine how we felt goaded and our next question was “Please tell us about some of the more advanced things you did with C# and .NET.”. The answer this time was rather disappointing and the things mentioned by the candidate where nowhere near bleeding edge. </li>
<li>Yet another developer, when asked what he did and where he is good at, did not talk about development or things a developer does and is proud of, but he rather started to talk about processes along and around development in general. It remained a “blah-blah” even when we insisted on hearing more “technical details”.</li>
</ul>
<p>If what a candidate tells us at the phone sounds interesting we arrange a face-to-face meeting. Sometimes we give the candidates some “home work” to do, to be prepared for the interview. Most often the topic of this home work are the S.O.L.I.D. principles. We just tell the candidates that this topic will be one of our discussion points during the interview.</p>
<p>During the face-to-face interview we do an exercise with the candidate. It is basically <em>coding in Notepad</em>. We are typing since the candidate might get too nervous if he had to type. (We all know that it is difficult to type when somebody watches you over your shoulders, do we?). The goal of this exercise is not that the candidate finds “the” correct answer (there might not be such a thing…) but we want to find out, how a candidate approaches a problem, how he is thinking and how he is refining his approach to a possible solution. The outcome of this exercise completely depends on the candidate and how he approaches things. While trying to find a solution we might discuss such topics as: programming against abstractions (using interfaces or dependency inversion principle), encapsulation, tell don’t ask principle, single responsibility principle, interface segregation principle, the usage of strategy patterns, etc. We do not expect that the candidate knows all this principles and patterns by name nor that he knows when and how to apply them but some of them might just naturally exhibit themselves during the exercise.</p>
<p>This exercise really separates candidates of good quality from those of mediocre or low quality. We had some candidates that did an excellent job although it was the first time they ever heard of all those principles and/or patterns and certainly have never applied them consciously before. Others that knew all patterns and principles by heart and could rephrase their definitions failed miserably when asked where those principles and patterns could be applied in the sample at hand.</p>
<p>Sadly developers of low quality are far more common than the ones of decent or high quality.</p>
<p>Even more sad is the fact that developers having a (very) limited skill set are most often not aware of this fact and consider themselves to be “seniors”.</p>
<p>Am I expecting too much? I don’t think so. Developers have I high responsibility. They produce software to automate business or mission critical processes. One should expect this software to be of high quality. To write high quality software we need good developers!</p>
]]></content:encoded>
			<wfw:commentRss>http://lostechies.com/gabrielschenker/2011/01/18/ranting-about-the-quality-of-developers/feed/</wfw:commentRss>
		<slash:comments>47</slash:comments>
		</item>
		<item>
		<title>NHibernate 3 Beginners Guide</title>
		<link>http://lostechies.com/gabrielschenker/2011/01/18/nhibernate-3-beginners-guide/</link>
		<comments>http://lostechies.com/gabrielschenker/2011/01/18/nhibernate-3-beginners-guide/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 03:58:19 +0000</pubDate>
		<dc:creator>Gabriel Schenker</dc:creator>
				<category><![CDATA[book]]></category>
		<category><![CDATA[introduction]]></category>
		<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">/blogs/gabrielschenker/archive/2011/01/18/nhibernate-3-beginners-guide.aspx</guid>
		<description><![CDATA[I am heading towards another mile stone in my life. Later this year my first book will be published. I have always wanted to write a book but never had a topic that is at the same time interesting for&#160;&#8230; <a href="http://lostechies.com/gabrielschenker/2011/01/18/nhibernate-3-beginners-guide/">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I am heading towards another mile stone in my life. Later this year my first book will be published. I have always wanted to write a book but never had a topic that is at the same time interesting for me and also of relevance to a publisher. After having reviewed my <a href="https://www.packtpub.com/nhibernate-3-0-cookbook/book">first book</a> lately, the publisher approached me whether I am not interested in writing a book myself. Happily I accepted this proposal. The book is about NHibernate, a topic which is very familiar to me as most of your readers might know. I have been writing a lot of posts about NHibernate in the past, mostly on the <a href="http://blogs.hibernatingrhinos.com/nhibernate/Default.aspx">NHibernate FAQ blog</a> and also posted some articles and tutorials on the <a href="http://nhforge.org/Default.aspx">NHibernate home page</a> and on <a href="http://dotnetslackers.com/articles/ado_net/Your-very-first-NHibernate-application-Part-1.aspx">DotNetSlackers</a> Web Site.</p>
<p>The title of the book is “NHibernate 3 Beginner Guide” and it will be published by <a href="http://www.packtpub.com/">Packt Publishing</a>. As the title tells it is an introduction to the most recent version of NHibernate. But in contrast to other books that have been written about NHibernate so far I want to address the topic in a little bit different way. My goal is to introduce this ORM framework by using a <strong>model centric</strong> view and not a data centric view. Consequently NHibernate is used to map the model to a data store and the details of the data store (although important) do not play the same central role as in many other texts.</p>
<p>As the book is an introduction to NHibernate I want to provide the reader a friction-less approach to how to use this ORM framework. In the spirit of this I will discuss topics as mapping entities to tables or configuring NHibernate mostly by using convention based approaches (e.g. ConfORM, Auto-mapping with Fluent NHibernate) or by using fluent APIs. XML based configuration and mapping will also be discussed, but only as “<strong>one</strong>” way to do things and not “<strong>the</strong>” way to do it.</p>
<p>Luckily ,while writing the book, I can leverage all the positive and negative experiences we’ve had in our day to day work with NHibernate. That led me to the conclusion that I absolutely have to add a chapter about “how you can screw up things with NHibernate…”. Of course, the title of the chapter will be different, but it will be fun.</p>
<p>At the time of writing I have already finished the first 3 chapters and “only” 8 chapters are left. Stay tuned…</p>
]]></content:encoded>
			<wfw:commentRss>http://lostechies.com/gabrielschenker/2011/01/18/nhibernate-3-beginners-guide/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>New book on NHibernate</title>
		<link>http://lostechies.com/gabrielschenker/2010/10/06/new-book-on-nhibernate/</link>
		<comments>http://lostechies.com/gabrielschenker/2010/10/06/new-book-on-nhibernate/#comments</comments>
		<pubDate>Wed, 06 Oct 2010 16:46:53 +0000</pubDate>
		<dc:creator>Gabriel Schenker</dc:creator>
				<category><![CDATA[book]]></category>
		<category><![CDATA[introduction]]></category>
		<category><![CDATA[NHibernate]]></category>
		<category><![CDATA[review]]></category>

		<guid isPermaLink="false">/blogs/gabrielschenker/archive/2010/10/06/new-book-on-nhibernate.aspx</guid>
		<description><![CDATA[Yesterday a new excellent book about NHibernate has been published by www.packtpub.com. (Disclosure: I have been a reviewer thus consider that when reading this post) The book is called “NHibernate 3.0 Cookbook” and can be ordered here. There is even&#160;&#8230; <a href="http://lostechies.com/gabrielschenker/2010/10/06/new-book-on-nhibernate/">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Yesterday a new excellent book about <strong>NHibernate</strong> has been published by <a href="http://www.packtpub.com">www.packtpub.com</a>. (Disclosure: I have been a reviewer thus consider that when reading this post)</p>
<p>The book is called “<strong>NHibernate 3.0 Cookbook</strong>” and can be ordered <a href="https://www.packtpub.com/nhibernate-3-0-cookbook/book">here</a>. There is even a discount available; please refer to <a href="http://fabiomaulo.blogspot.com/2010/10/nhibernate-30-cookbook.html">this</a> post of Fabio Maulo.</p>
<p>This is so far the best and most complete book I ever held in my hands. It covers <strong>NHibernate 3.0</strong> and thus is really up to date. The author has done a tremendous job in covering all the important aspects of interest when implementing business relevant solutions. The book is very focused and gives a step by step introduction into all the necessary details to get a solution up an running. No space is wasted for (potentially) unimportant details.</p>
<p>One of the things I like most is that the book/the author does not have a data centric view but is more domain focused.</p>
]]></content:encoded>
			<wfw:commentRss>http://lostechies.com/gabrielschenker/2010/10/06/new-book-on-nhibernate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

