<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
<channel>
<title>The Archidev</title>
<link>http://omarbesiso.typepad.com/the-archidev/</link>
<description>Defying Everyday Architectures</description>
<language>en-AU</language>
<lastBuildDate>Wed, 24 Nov 2010 14:56:11 +1100</lastBuildDate>
<generator>http://www.typepad.com/</generator>

<docs>http://www.rssboard.org/rss-specification</docs>
<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/OmarBesiso" /><feedburner:info uri="omarbesiso" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
<title>CodeCampOZ 2010</title>
<link>http://feedproxy.google.com/~r/OmarBesiso/~3/u0sEIlP8vOE/codecampoz-2010.html</link>
<guid isPermaLink="false">http://omarbesiso.typepad.com/the-archidev/2010/11/codecampoz-2010.html</guid>
<description>I had the pleasure of speaking at code camp OZ again this year and I had a ball. I’d like to extend my gratitude to Mitch Denny for giving us our geeky break every year. In my cumbersome 2 hour session I spoke about DDD, Entity Framework and design patterns. Please find the presentation here. And the two projects for the presentation can be found below. Enjoy and as usual don’t hesitate to come back with questions.</description>
<content:encoded><![CDATA[<p>I had the pleasure of speaking at code camp OZ again this year and I had a ball. I’d like to extend my gratitude to Mitch Denny for giving us our geeky break every year. </p>  <p>In my cumbersome 2 hour session I spoke about DDD, Entity Framework and design patterns. </p>  <p>Please find the presentation here.</p> <iframe style="padding-bottom: 0px; background-color: #fcfcfc; padding-left: 0px; width: 98px; padding-right: 0px; height: 115px; padding-top: 0px" title="Preview" marginheight="0" src="http://cid-70a5b53d721071b7.office.live.com/embedicon.aspx/Public/Presentations/CodeCampOz2010.pdf" frameborder="0" marginwidth="0" scrolling="no"></iframe>  <p>And the two projects for the presentation can be found below.</p> <iframe style="padding-bottom: 0px; background-color: #fcfcfc; padding-left: 0px; width: 98px; padding-right: 0px; height: 115px; padding-top: 0px" title="Preview" marginheight="0" src="http://cid-70a5b53d721071b7.office.live.com/embedicon.aspx/Public/Source%20Code/EntityFrameworkSelfTrackingDemo.zip" frameborder="0" marginwidth="0" scrolling="no"></iframe><iframe style="padding-bottom: 0px; background-color: #fcfcfc; padding-left: 0px; width: 98px; padding-right: 0px; height: 115px; padding-top: 0px" title="Preview" marginheight="0" src="http://cid-70a5b53d721071b7.office.live.com/embedicon.aspx/Public/Source%20Code/SmartDocStore.zip" frameborder="0" marginwidth="0" scrolling="no"></iframe>  <p>Enjoy and as usual don’t hesitate to come back with questions.</p><img src="http://feeds.feedburner.com/~r/OmarBesiso/~4/u0sEIlP8vOE" height="1" width="1"/>]]></content:encoded>



<dc:creator>The Archidev</dc:creator>
<pubDate>Wed, 24 Nov 2010 14:56:11 +1100</pubDate>

<feedburner:origLink>http://omarbesiso.typepad.com/the-archidev/2010/11/codecampoz-2010.html</feedburner:origLink></item>
<item>
<title>Talking Shop</title>
<link>http://feedproxy.google.com/~r/OmarBesiso/~3/8WrJ1Fm1uVo/talking-shop.html</link>
<guid isPermaLink="false">http://omarbesiso.typepad.com/the-archidev/2010/03/talking-shop.html</guid>
<description>OK this is a repeat of Paul Stovell’s recent blog announcing his talk on Talk Shop. So because I am lazy here is a repeat of Paul’s Post. http://www.paulstovell.com/talking-shop Richard Banks started a podcast series with a focus on Australian developers called Talking Shop. Last week he was kind enough to interview me about WPF, Magellan, and a number of other (un)related topics. Talking Shop Episode 5 Don't forget to check out the earlier episodes: Paul Batum Joe Albahari Matt Hamilton Scott Barnes</description>
<content:encoded><![CDATA[<p>OK this is a repeat of Paul Stovell’s recent blog announcing his talk on Talk Shop. So because I am lazy here is a repeat of Paul’s Post.</p>  <p><a title="http://www.paulstovell.com/talking-shop" href="http://www.paulstovell.com/talking-shop">http://www.paulstovell.com/talking-shop</a></p>  <p><a href="http://twitter.com/rbanks54"><em>Richard Banks</em></a><em> started a podcast series with a focus on Australian developers called <strong><a href="http://www.talkingshopdownunder.com/">Talking Shop</a></strong>. Last week he was kind enough to interview me about WPF, Magellan, and a number of other (un)related topics. </em></p>  <p><strong><a href="http://www.talkingshopdownunder.com/2010/03/episode-5-magellan-and-more-with-paul.html"><em>Talking Shop Episode 5</em></a></strong></p>  <p><em>Don't forget to check out the earlier episodes:</em></p>  <ul>   <li><a href="http://www.talkingshopdownunder.com/2010/03/talking-shop-down-under-podcast-episode.html"><em>Paul Batum</em></a></li>    <li><a href="http://www.talkingshopdownunder.com/2010/03/episode-3-joe-albahari-on-linqpad.html"><em>Joe Albahari</em></a></li>    <li><a href="http://www.talkingshopdownunder.com/2010/02/episode-2-open-source-and-twitter-with.html"><em>Matt Hamilton</em></a></li>    <li><a href="http://www.talkingshopdownunder.com/2010/02/episode-1-interview-with-scott-barnes.html"><em>Scott Barnes</em></a></li> </ul><img src="http://feeds.feedburner.com/~r/OmarBesiso/~4/8WrJ1Fm1uVo" height="1" width="1"/>]]></content:encoded>


<category>Developers</category>
<category>Events</category>

<dc:creator>The Archidev</dc:creator>
<pubDate>Tue, 16 Mar 2010 11:32:37 +1100</pubDate>

<feedburner:origLink>http://omarbesiso.typepad.com/the-archidev/2010/03/talking-shop.html</feedburner:origLink></item>
<item>
<title>Paul Glavich: Performance Testing and Optimisation</title>
<link>http://feedproxy.google.com/~r/OmarBesiso/~3/WFHHY6iocqo/paul-glavich-performance-testing-and-optimisation.html</link>
<guid isPermaLink="false">http://omarbesiso.typepad.com/the-archidev/2010/01/paul-glavich-performance-testing-and-optimisation.html</guid>
<description>The first part of fellow Datacom architect Paul Glavich’s Performance Testing and Optimisation book has been released at http://www.red-gate.com/products/ants_performance_profiler/care_about_performance_ebook.htm. What a read that was. Brief: In this complete guide to performance profiling, Paul Glavich and Chris Farrell explain why performance testing is a good idea and walk you through everything you need to know to set up a test environment. This comprehensive guide to getting started is an essential handbook to any programmer looking to set up a .NET testing environment and get the best results out of it. Download your free copy now. Happy Testing!</description>
<content:encoded><![CDATA[<p>The first part of fellow Datacom architect Paul Glavich’s Performance Testing and Optimisation book has been released at <a href="http://www.red-gate.com/products/ants_performance_profiler/care_about_performance_ebook.htm">http://www.red-gate.com/products/ants_performance_profiler/care_about_performance_ebook.htm</a>. </p>  <p>What a read that was.</p>  <p>Brief:</p>  <blockquote>   <p><em>In this complete guide to performance profiling, Paul Glavich and Chris Farrell explain why performance testing is a good idea and walk you through everything you need to know to set up a test environment. This comprehensive guide to getting started is an essential handbook to any programmer looking to set up a .NET testing environment and get the best results out of it. Download your free copy now.</em></p> </blockquote>  <p>&#160;</p>  <p>Happy Testing!</p><img src="http://feeds.feedburner.com/~r/OmarBesiso/~4/WFHHY6iocqo" height="1" width="1"/>]]></content:encoded>


<category>Architecture</category>
<category>Developers</category>

<dc:creator>The Archidev</dc:creator>
<pubDate>Sat, 30 Jan 2010 02:25:00 +1100</pubDate>

<feedburner:origLink>http://omarbesiso.typepad.com/the-archidev/2010/01/paul-glavich-performance-testing-and-optimisation.html</feedburner:origLink></item>
<item>
<title>What&amp;rsquo;s In a Method?</title>
<link>http://feedproxy.google.com/~r/OmarBesiso/~3/7iLi6P3szj4/whats-in-a-method.html</link>
<guid isPermaLink="false">http://omarbesiso.typepad.com/the-archidev/2009/09/whats-in-a-method.html</guid>
<description>In every composition made in day to day lives there are always the building blocks that the composition is ‘composed’ of. A house is composed from bricks. A book is composed of words. A compound is made of molecules and humans of cells. Then there are complex compositions that are composed of other simple compositions. Regardless of what you look at though, the quality of the composition is always dependent on the smallest unit that builds it. So in software what is the smallest building block, is it the variables, the classes etc.? Well I vote for methods. To me...</description>
<content:encoded><![CDATA[<p>In every composition made in day to day lives there are always the building blocks that the composition is ‘composed’ of. A house is composed from bricks. A book is composed of words. A compound is made of molecules and humans of cells. Then there are complex compositions that are composed of other simple compositions. Regardless of what you look at though, the quality of the composition is always dependent on the smallest unit that builds it. So in software what is the smallest building block, is it the variables, the classes etc.? Well I vote for methods. To me it’s the quality of the methods composing the application is what makes all the difference. When we unit test, we do so most of the time on a method. While usually forgotten with all the technology centric and high-level views we take on software, your method is still your most important asset. So what’s in a method?</p>  <h3></h3>  <h3>Beginner Developers</h3>  <p>A method will usually be written to achieve a single function. At least simple methods will. Methods can do that by either running some simple statements or by leveraging other methods. But for this post let’s concentrate on how you would look at a method with simple statements. </p>  <p>The following static method divides two numbers.</p>  <div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">   <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"><span style="color: #0000ff">static</span> <span style="color: #0000ff">double</span> Divide(<span style="color: #0000ff">double</span> x, <span style="color: #0000ff">double</span> y)<br />{<br />    <span style="color: #0000ff">return</span> x/y;<br />}</pre>

  <br /></div>

<p>By making this method static we already decided that the method can be called without the instantiation of an object, The second step that a beginner developer will decide is usually the scope of the method. Is it private or public? Let’s say for now that the method is public.</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">double</span> Divide(<span style="color: #0000ff">double</span> x, <span style="color: #0000ff">double</span> y)<br />{<br />    <span style="color: #0000ff">return</span> x/y;<br />}</pre>

  <br /></div>

<p>So far we have established the following characteristics of the method:</p>

<ul>
  <li>The method divides two numbers. </li>

  <li>The method can be called without instantiating an object. </li>

  <li>The method can be called from outside the containing class. </li>
</ul>

<p>Most of the time this is usually where a beginner developer would stop.</p>

<h3>Junior Developer</h3>

<p>A junior developer with several months experience will know that this is not the end of it. The developer will usually add more characteristics to the method and consider where the method can fail by analysing possible failure points. For example, knowing that if y is 0 the method will throw an exception the developer will arm his method with a validation mechanism. Perhaps throw an exception of his own. The junior developer can also dislike the naming strategy so he renames variables to make things clearer.</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">double</span> Divide(<span style="color: #0000ff">double</span> dividend, <span style="color: #0000ff">double</span> divisor)<br />{<br />    <span style="color: #0000ff">if</span>(divisor == 0)<br />    {<br />        <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ArgumentException(<span style="color: #006080">&quot;divisor cannot be zero&quot;</span>, <span style="color: #006080">&quot;divisor&quot;</span>);<br />    }<br />    <span style="color: #0000ff">return</span> dividend/divisor;<br />}</pre>

  <br /></div>

<p>The characteristics of the method, after being touched by the junior developer became:</p>

<ul>
  <li>The method divides two numbers. </li>

  <li>The method can be called without instantiating an object. </li>

  <li>The method can be called from outside the containing class. </li>

  <li>The method is more readable. </li>

  <li>The method validates for a divisor being 0. </li>
</ul>

<h3>Intermediate Developer</h3>

<p>When the developer gets to an intermediate stage he\she starts thinking about reusability and neat code. The developer wants to be able to use an extension method to facilitate calling the code from any double variable in the application with no class calls. So a static class is created and a helper extension method follows. </p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">class</span> ArithmeticHelpers<br />{<br />    <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">double</span> DivideBy(<span style="color: #0000ff">this</span> <span style="color: #0000ff">double</span> dividend, <span style="color: #0000ff">double</span> divisor)<br />    {<br />        <span style="color: #0000ff">if</span> (divisor == 0)<br />        {<br />            <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ArgumentException(<span style="color: #006080">&quot;divisor cannot be zero&quot;</span>, <span style="color: #006080">&quot;divisor&quot;</span>);<br />        }<br />        <span style="color: #0000ff">return</span> dividend / divisor;<br />    }<br />}</pre>

  <br /></div>

<p>The characteristics of the method, after being touched by the junior developer became:</p>

<blockquote>
  <li>The method divides two numbers. </li>

  <li>The method can be called without instantiating an object. </li>

  <li>The method can be called from outside the containing class. </li>

  <li>The method is more readable. </li>

  <li>The method validates for a divisor being 0. </li>

  <li>The method is more re-usable and can be applied through any double type variable. </li>
</blockquote>

<h3>Senior Developer </h3>

<p>Our developer now gets to a senior level. The developer glances over his old code and finds that the method is next to perfect. One thing he wants to make sure of, is that if any other developer changes the method with breaking changes (ones that do not meet expectations) a notification will arise. So the senior developer decides to write some unit tests trying to cover all his possibilities.</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">[TestMethod]<br />[ExpectedException(<span style="color: #0000ff">typeof</span> (ArgumentException),<br />    <span style="color: #006080">&quot;The Divisor cannot be zero.&quot;</span>)]<br /><span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> DivisionTestCase1()<br />{<br />    <span style="color: #0000ff">const</span> <span style="color: #0000ff">double</span> num1 = 10;<br />    <span style="color: #0000ff">const</span> <span style="color: #0000ff">double</span> num2 = 0;<br /><br />    num1.DivideBy(num2);<br />}<br /><br />[TestMethod]<br /><span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> DivisionTestCase2()<br />{<br />    <span style="color: #0000ff">const</span> <span style="color: #0000ff">double</span> num1 = 10;<br />    <span style="color: #0000ff">const</span> <span style="color: #0000ff">double</span> num2 = 2;<br /><br />    Debug.Assert(num1.DivideBy(num2) == 5);<br /><br />    <span style="color: #0000ff">const</span> <span style="color: #0000ff">double</span> num3 = <span style="color: #0000ff">double</span>.MaxValue;<br />    <span style="color: #0000ff">const</span> <span style="color: #0000ff">double</span> num4 = <span style="color: #0000ff">double</span>.MinValue;<br /><br />    Debug.Assert(num3.DivideBy(num4) == -1);<br />    Debug.Assert(<span style="color: #0000ff">double</span>.IsInfinity(num3.DivideBy(0.1)));<br />    Debug.Assert(<span style="color: #0000ff">double</span>.IsNegativeInfinity(num3.DivideBy(-0.1)));<br />}</pre>

  <br /></div>

<p>Wow, our method is getting richer by the minute and the characteristics are now: </p>

<blockquote>
  <li>The method divides two numbers. </li>

  <li>The method can be called without instantiating an object. </li>

  <li>The method can be called from outside the containing class. </li>

  <li>The method is more readable. </li>

  <li>The method validates for a divisor being 0. </li>

  <li>The method is more re-usable and can be applied through any double type variable. </li>

  <li>The method is tested and unit tests will indicate any breaking changes. </li>
</blockquote>

<h3>Architects \ Team Leads &amp; People you can’t Please</h3>

<p>What an annoying bunch of people those are (just kidding for the sensitive kind :)). Now an architect looks at the method which is almost perfect and think to himself “How can I make something this good better?” The architect then identifies the “junction points of a method”. If you were at our (Paul Stovell and I) talk at CodeCampOz you would know what junction points are and those can be defined by the following diagram.</p>

<p>&#160;<a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a570ba83970b-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5c7528a970c-pi" width="499" height="377" /></a> </p>

<p>The architect now decides that the method needs to be auditable and exceptions needs to be handled by a policy. In other words, that nosy architect wants to use Aspect Oriented Programming to handle the cross cutting concerns of the method. For this he leverages <a href="http://www.postsharp.org">PostSharp</a> and creates a couple of aspects. </p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">[Serializable]<br /><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> OnDivideByInvocationAspect : OnMethodInvocationAspect<br />{<br />    <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">void</span> OnInvocation(MethodInvocationEventArgs context)<br />    {<br />        Trace.TraceInformation(<span style="color: #006080">&quot;Entering {0}.&quot;</span>, context.Method); <br />        context.Proceed();<br />        Trace.TraceInformation(<span style="color: #006080">&quot;Leaving {0}.&quot;</span>, context.Method); <br />    }<br />}</pre>

  <br /></div>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">[Serializable]<br /><span style="color: #0000ff">public</span> <span style="color: #0000ff">sealed</span> <span style="color: #0000ff">class</span> OnDivideByExceptionAspect : OnExceptionAspect<br />{<br />    <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">void</span> OnException(MethodExecutionEventArgs eventArgs)<br />    {<br />        <span style="color: #0000ff">if</span> (eventArgs.Exception.GetType() == <span style="color: #0000ff">typeof</span>(ArgumentException) &amp;&amp;<br />            eventArgs.Exception.Message.Equals(<span style="color: #006080">&quot;The Divisor cannot be zero.&quot;</span>))<br />        {<br />            Trace.TraceInformation(eventArgs.Exception.Message);<br />        }<br /><br />        eventArgs.FlowBehavior = FlowBehavior.RethrowException;<br />    }<br />}</pre>

  <br /></div>

<p>Now our method looks something like this.</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">[OnDivideByExceptionAspect]<br />[OnDivideByInvocationAspect]<br /><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">double</span> DivideBy(<span style="color: #0000ff">this</span> <span style="color: #0000ff">double</span> dividend, <span style="color: #0000ff">double</span> divisor)<br />{<br />    <span style="color: #0000ff">if</span> (divisor == 0)<br />    {<br />        <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ArgumentException(<span style="color: #006080">&quot;The Divisor cannot be zero.&quot;</span>, <span style="color: #006080">&quot;divisor&quot;</span>);<br />    }<br />    <span style="color: #0000ff">return</span> dividend / divisor;<br />}</pre>

  <br /></div>

<p>Only thing is when you thought it’s almost over, another architect does a further refinement to the exception aspect and wants less code in the method so now he goes and….does this.</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">[Serializable]<br /><span style="color: #0000ff">public</span> <span style="color: #0000ff">sealed</span> <span style="color: #0000ff">class</span> OnDivideByExceptionAspect : OnExceptionAspect<br />{<br />    <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">void</span> OnException(MethodExecutionEventArgs eventArgs)<br />    {<br />        <span style="color: #0000ff">if</span> (eventArgs.Exception.GetType() == <span style="color: #0000ff">typeof</span>(DivideByZeroException))<br />        {<br />            Trace.TraceInformation(eventArgs.Exception.Message);<br />        }<br /><br />        eventArgs.FlowBehavior = FlowBehavior.RethrowException;<br />    }<br />}</pre>

  <br /></div>

<p>and now the method looks like:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">[OnDivideByExceptionAspect]<br />[OnDivideByInvocationAspect]<br /><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">double</span> DivideBy(<span style="color: #0000ff">this</span> <span style="color: #0000ff">double</span> dividend, <span style="color: #0000ff">double</span> divisor)<br />{<br />    <span style="color: #0000ff">return</span> dividend / divisor;<br />}</pre>

  <br /></div>

<p></p>

<p></p>

<p></p>

<p></p>

<p></p>

<p></p>

<p></p>

<p></p>

<p></p>

<p></p>

<p></p>

<p>Wow almost a full circle and now one more characteristic is:</p>

<ul>
  <li>The method divides two numbers. </li>

  <li>The method can be called without instantiating an object. </li>

  <li>The method can be called from outside the containing class. </li>

  <li>The method is more readable. </li>

  <li><strong><em>The method validates for a divisor being 0. (but with a twist)</em></strong> </li>

  <li>The method is more re-usable and can be applied through any double type variable. </li>

  <li>The method is tested and unit tests will indicate any breaking changes. </li>

  <li><strong>The code is concise to the problem at hand – division.</strong> </li>
</ul>

<h3></h3>

<h3>Conclusion</h3>

<p>I wrote this post inspired by various discussion with developers over @ Datacom. The boundaries I drew between the different levels of developers here are only an example and do not necessarily resemble real life. This post was also never meant to say the applying AOP is always the perfect end solution. I wrote this post to point your attention to the importance of investing time in the quality of your simplest and smallest building block, the method. The method shown in this post is a simple division one yet we managed to think about it and implement it in various ways. Everyday in your coding life, pay attention to your methods. The journey didn’t finish when the fictitious architect was done with applying AOP nor do the steps in this post conclude your ‘method perfection journey’. Of the top of my head I think this method is yet to be performance tested, memory profiled and dependency analysed :) </p>

<p>Your method is your core building block. If it is of high quality then you got more chance of success with whatever software you’re building. I believe if you just spend 5 minutes gazing at a method after you wrote it, you will have more chance of making it better. </p>

<p>Enjoy!</p><img src="http://feeds.feedburner.com/~r/OmarBesiso/~4/7iLi6P3szj4" height="1" width="1"/>]]></content:encoded>


<category>Developers</category>

<dc:creator>The Archidev</dc:creator>
<pubDate>Tue, 15 Sep 2009 23:38:50 +1000</pubDate>

<feedburner:origLink>http://omarbesiso.typepad.com/the-archidev/2009/09/whats-in-a-method.html</feedburner:origLink></item>
<item>
<title>TechEd 2009</title>
<link>http://feedproxy.google.com/~r/OmarBesiso/~3/kW9wgWYqR7E/teched-2009.html</link>
<guid isPermaLink="false">http://omarbesiso.typepad.com/the-archidev/2009/09/teched-2009.html</guid>
<description>It was a blast. For me TechEd Australia tends to be the Geek holiday I get every year. This year though, it was very special on many levels. With the biggest mini notebook handout TechEd proved to give everyone something to remember. Something about it’s size compared to my XPS made me feel sorry for the mini though :) My Participation This year witnessed my biggest participation so far in TechEd. With a Tech Talk with Paul Glavich and a WPF Composite Framework breakout session and two Bird of Feathers sessions I couldn’t possibly be any happier. Tech Talk: Enterprise...</description>
<content:encoded><![CDATA[<p>It was a blast. For me TechEd Australia tends to be the Geek holiday I get every year. This year though, it was very special on many levels. With the biggest mini notebook handout TechEd proved to give everyone something to remember. Something about it’s size compared to my XPS made me feel sorry for the mini though :)</p>  <p><a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5c285c9970c-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDC10298" border="0" alt="SDC10298" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5c285cb970c-pi" width="244" height="184" /></a> <a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5c285d0970c-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="3882781207_d5b05cb840" border="0" alt="3882781207_d5b05cb840" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a56be913970b-pi" width="244" height="184" /></a> </p>  <p>&#160;</p>  <h1></h1>  <h1>My Participation</h1>  <p>This year witnessed my biggest participation so far in TechEd. With a Tech Talk with Paul Glavich and a WPF Composite Framework breakout session and two Bird of Feathers sessions I couldn’t possibly be any happier.</p>  <h2>Tech Talk: Enterprise Software</h2>  <p>The master of disaster, fellow Architect Paul Glavich took the time to interview me and it was fun talking Enterprise Applications with the man who knows it all. Check out the video here.</p>  <p><a href="http://www.msteched.com/online/view.aspx?tid=330697c7-f29b-4312-bbdf-6b6d171dd2c6 "><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Capture" border="0" alt="Capture" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5c2b19b970c-pi" width="244" height="140" /></a> </p>  <p></p>  <h2>Breakout Session: WPF Composite Framework</h2>  <p>For a while now I have been using the Composite Framework to architect and build rich client applications and a shout out goes to Paul Stovell who showed me this for the first time. I took the audience on a trip around the concepts and implementations of the Composite Framework. While the feedback was a bit mixed I think for a wide topic the audience managed to see the benefit of the Composite framework in building modular interfaces. All the code can be downloaded here.</p> <iframe style="padding-bottom: 0px; background-color: #fcfcfc; padding-left: 0px; width: 98px; padding-right: 0px; height: 115px; padding-top: 0px" title="Preview" marginheight="0" src="http://cid-70a5b53d721071b7.skydrive.live.com/embedicon.aspx/Public/Source%20Code/CompositeRss.zip" frameborder="0" marginwidth="0" scrolling="no"></iframe>  <p>&#160;</p>  <h2>BOF Sessions : PostSharp &amp; LightSpeed</h2>  <p>I also got to do a couple of short sessions on PostSharp <a href="http://www.postsharp.org/)">(http://www.postsharp.org/)</a> and LightSpeed (<a href="http://www.mindscape.co.nz/products/lightspeed/">http://www.mindscape.co.nz/products/lightspeed/</a> ). Again a big shout out goes out to the guys from Mindscape for providing free licences to give away during the session. You can download the code for the PostSharp Session here.</p> <iframe style="padding-bottom: 0px; background-color: #fcfcfc; padding-left: 0px; width: 98px; padding-right: 0px; height: 115px; padding-top: 0px" title="Preview" marginheight="0" src="http://cid-70a5b53d721071b7.skydrive.live.com/embedicon.aspx/Public/Source%20Code/PostSharpDemo.zip" frameborder="0" marginwidth="0" scrolling="no"></iframe>  <p>&#160;</p>  <h1>Conclusion</h1> Finally, TechEd wouldn't have been such a hit without the efforts of all the Microsoft veterans but I feel a special thank you should go out to Andrew Coates and Michael Kordahi who made this event the greatest event of the year.   <p><a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5c285df970c-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDC10418" border="0" alt="SDC10418" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a56be91e970b-pi" width="244" height="184" /></a> <a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5c285e8970c-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDC10408" border="0" alt="SDC10408" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5c285f0970c-pi" width="244" height="184" /></a> </p>  <p>and as usual not to be forgotten the boys from Readify and their ever entertaining company</p>  <p><a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5c285f8970c-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDC10413" border="0" alt="SDC10413" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5c285fd970c-pi" width="244" height="184" /></a></p><img src="http://feeds.feedburner.com/~r/OmarBesiso/~4/kW9wgWYqR7E" height="1" width="1"/>]]></content:encoded>


<category>Events</category>

<dc:creator>The Archidev</dc:creator>
<pubDate>Mon, 14 Sep 2009 21:49:11 +1000</pubDate>

<feedburner:origLink>http://omarbesiso.typepad.com/the-archidev/2009/09/teched-2009.html</feedburner:origLink></item>
<item>
<title>First Day at TechEd 2009</title>
<link>http://feedproxy.google.com/~r/OmarBesiso/~3/oX0098RCqh0/first-day-at-teched-2009.html</link>
<guid isPermaLink="false">http://omarbesiso.typepad.com/the-archidev/2009/09/first-day-at-teched-2009.html</guid>
<description>This year I have the privilege of speaking at TechEd 2009 at the Gold Coast. It was a great first day today with speaker briefing and then the welcome party (pictures below). If you’re at TechEd this year you would be pleased to know (depending if you know me or not) that I have a couple of talks happening so feel free to drop by. WEB305 Modular User Interfaces: Easier than Ever (Thu 9/10 | 11:30-12:45 | Arena 1B) BOF006 LightSpeed: An ORM not to be missed. (Fri 9/11 | 12:45-13:45 | Meeting Room 7) Lightning Talk about PostsSharp on...</description>
<content:encoded><![CDATA[<p>This year I have the privilege of speaking at TechEd 2009 at the Gold Coast. It was a great first day today with speaker briefing and then the welcome party (pictures below). If you’re at TechEd this year you would be pleased to know (depending if you know me or not) that I have a couple of talks happening so feel free to drop by.</p>  <p>WEB305 Modular User Interfaces: Easier than Ever (Thu 9/10 | 11:30-12:45 | Arena 1B)</p>  <p>BOF006 LightSpeed: An ORM not to be missed. (Fri 9/11 | 12:45-13:45 | Meeting Room 7)</p>  <p>Lightning Talk about PostsSharp on Thursday Lunch time with Richard Bank and the Alt.NET exponanza and a tech talk with the Amazing Paul Glavich. </p>  <p>Here are some photos from today:</p>  <p><a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5575eed970b-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDC10304" border="0" alt="SDC10304" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5575ef7970b-pi" width="244" height="184" /></a> <a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5575efb970b-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDC10310" border="0" alt="SDC10310" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5575f05970b-pi" width="244" height="184" /></a> <a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5add8d7970c-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDC10301" border="0" alt="SDC10301" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5add8dd970c-pi" width="244" height="184" /></a> <a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5add8e9970c-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDC10305" border="0" alt="SDC10305" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5add8f0970c-pi" width="244" height="184" /></a> <a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5add8fa970c-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDC10308" border="0" alt="SDC10308" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5575f24970b-pi" width="244" height="184" /></a> <a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5add908970c-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDC10309" border="0" alt="SDC10309" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5575f3b970b-pi" width="244" height="184" /></a> <a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5575f48970b-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDC10298" border="0" alt="SDC10298" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5575f53970b-pi" width="244" height="184" /></a> <a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5575f5d970b-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDC10313" border="0" alt="SDC10313" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5add924970c-pi" width="244" height="184" /></a> <a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5add931970c-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDC10354" border="0" alt="SDC10354" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5575f6e970b-pi" width="244" height="184" /></a> <a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5add937970c-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDC10358" border="0" alt="SDC10358" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5575f77970b-pi" width="244" height="184" /></a> <a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5add94b970c-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDC10318" border="0" alt="SDC10318" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5add953970c-pi" width="244" height="184" /></a> <a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5575f88970b-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDC10333" border="0" alt="SDC10333" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5575f8e970b-pi" width="244" height="184" /></a> <a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5575f95970b-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDC10346" border="0" alt="SDC10346" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5575fa0970b-pi" width="244" height="184" /></a> <a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5add967970c-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDC10353" border="0" alt="SDC10353" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5add970970c-pi" width="244" height="184" /></a> <a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5575fbb970b-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDC10332" border="0" alt="SDC10332" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5575fc4970b-pi" width="244" height="184" /></a> <a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5add97f970c-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDC10351" border="0" alt="SDC10351" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5add987970c-pi" width="244" height="184" /></a> <a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5575fd5970b-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDC10347" border="0" alt="SDC10347" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5575fdd970b-pi" width="244" height="184" /></a> <a href="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5add99d970c-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDC10349" border="0" alt="SDC10349" src="http://omarbesiso.typepad.com/.a/6a0120a4e3f2a4970b0120a5add9a8970c-pi" width="244" height="184" /></a></p><img src="http://feeds.feedburner.com/~r/OmarBesiso/~4/oX0098RCqh0" height="1" width="1"/>]]></content:encoded>


<category>Events</category>

<dc:creator>The Archidev</dc:creator>
<pubDate>Tue, 08 Sep 2009 23:55:53 +1000</pubDate>

<feedburner:origLink>http://omarbesiso.typepad.com/the-archidev/2009/09/first-day-at-teched-2009.html</feedburner:origLink></item>
<item>
<title>Moved to Typepad </title>
<link>http://feedproxy.google.com/~r/OmarBesiso/~3/iiq9_6n9BsU/moved-to-typepad-.html</link>
<guid isPermaLink="false">http://omarbesiso.typepad.com/the-archidev/2009/08/moved-to-typepad-.html</guid>
<description>I have moved my posts here. While live spaces is great I thought it's time for a more professional look. My live spaces blog will still be up for old posts, images etc. omarbesiso.live.spaces.com</description>
<content:encoded><![CDATA[I have moved my posts here. While live spaces is great I thought it&#39;s time for a more professional look. My live spaces blog will still be up for old posts, images etc. omarbesiso.live.spaces.com<img src="http://feeds.feedburner.com/~r/OmarBesiso/~4/iiq9_6n9BsU" height="1" width="1"/>]]></content:encoded>


<category>General</category>

<dc:creator>The Archidev</dc:creator>
<pubDate>Thu, 20 Aug 2009 23:05:48 +1000</pubDate>

<feedburner:origLink>http://omarbesiso.typepad.com/the-archidev/2009/08/moved-to-typepad-.html</feedburner:origLink></item>
<item>
<title>ADNUG User Group &amp;ndash; Building Enterprise Applications</title>
<link>http://feedproxy.google.com/~r/OmarBesiso/~3/vMZA0hqT1c0/adnug-user-group-building-enterprise-applications.html</link>
<guid isPermaLink="false">http://omarbesiso.typepad.com/the-archidev/2009/08/adnug-user-group-building-enterprise-applications.html</guid>
<description>On Tuesday the 7th of July I had the privilege and pleasure to present at the Adelaide .NET User Group. It was such a fantastic experience considering it was my first time in Adelaide and I got to catch up with my good old friend and mentor Darren Neimke. I got to present for the first time on my adapted “Building Enterprise Applications” talk where I spoke about my experiences in my relatively new role in Datacom and some new devised guidelines on building Enterprise Software. You can download the slides of the talk here.





Looking forward to CodeCampSA next weekend where I will be presenting on the Sync Framework.</description>
<content:encoded><![CDATA[<p>On Tuesday the 7th of July I had the privilege and pleasure to present at the Adelaide .NET User Group. It was such a fantastic experience considering it was my first time in Adelaide and I got to catch up with my good old friend and mentor Darren Neimke. I got to present for the first time on my adapted “Building Enterprise Applications” talk where I spoke about my experiences in my relatively new role in Datacom and some new devised guidelines on building Enterprise Software. You can download the slides of the talk here.</p>
<p><iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-70a5b53d721071b7.skydrive.live.com/embedrowdetail.aspx/Public/Presentations/Building Enterprise Applications.pdf" style="BORDER-BOTTOM: #dde5e9 1px solid; BORDER-LEFT: #dde5e9 1px solid; PADDING-BOTTOM: 0px; BACKGROUND-COLOR: #ffffff; MARGIN: 3px; PADDING-LEFT: 0px; WIDTH: 240px; PADDING-RIGHT: 0px; HEIGHT: 66px; BORDER-TOP: #dde5e9 1px solid; BORDER-RIGHT: #dde5e9 1px solid; PADDING-TOP: 0px"></iframe></p>
<br />
<p>Looking forward to <a href="http://www.codecampsa.com/" target="_blank">CodeCampSA</a> next weekend where I will be presenting on the Sync Framework. </p><img src="http://feeds.feedburner.com/~r/OmarBesiso/~4/vMZA0hqT1c0" height="1" width="1"/>]]></content:encoded>


<category>Events</category>

<dc:creator>The Archidev</dc:creator>
<pubDate>Tue, 11 Aug 2009 23:06:07 +1000</pubDate>

<feedburner:origLink>http://omarbesiso.typepad.com/the-archidev/2009/08/adnug-user-group-building-enterprise-applications.html</feedburner:origLink></item>
<item>
<title>Parso&amp;rsquo;s World&amp;rsquo;s Greatest Shave</title>
<link>http://feedproxy.google.com/~r/OmarBesiso/~3/_c5ecJ5BdJc/parsos-worlds-greatest-shave.html</link>
<guid isPermaLink="false">http://omarbesiso.typepad.com/the-archidev/2009/08/parsos-worlds-greatest-shave.html</guid>
<description>On Friday I had the pleasure of catching up with my very good friend Andrew Parsons at Microsoft for lunch. Just as it happens, it was the World’s Greatest Shave event and Parso had volunteered to get a shave. I even paid 20 bucks to shave a portion of Andrew’s hair myself. Here’s for Parso, http://tinyurl/VirtualShave . 

View Full Album</description>
<content:encoded><![CDATA[<p>On Friday I had the pleasure of catching up with my very good friend Andrew Parsons at Microsoft for lunch. Just as it happens, it was the World’s Greatest Shave event and Parso had volunteered to get a shave. I even paid 20 bucks to shave a portion of Andrew’s hair myself. Here’s for Parso, <a href="http://tinyurl/VirtualShave">http://tinyurl/VirtualShave</a> . </p>
<div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px"><a href="http://cid-70a5b53d721071b7.skydrive.live.com/redir.aspx?page=browse&amp;resid=70A5B53D721071B7!499&amp;ct=photos" style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px"><img alt="View Parso&#39;s World Greatest Shave" src="https://saakya.bay.livefilestore.com/y1mDqjj2fJ_jAe_8ZJGzpc774YqYFgw8swt1JUKreUwS2nwM9SK02hivbu1KvfTKAexsCZtlDOWNzQeH6OEOH2BVgPtpRtmn1Isrvcv410Vv0B2PtarNwLjw0QfN_i9Fk-O9x-Mdq9Lphc/InlineRepresentation2c589777-1cd8-49da-a907-a4f5f97da757[3].jpg" style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" /></a> 
<div style="TEXT-ALIGN: right; WIDTH: 744px"><a href="http://cid-70a5b53d721071b7.skydrive.live.com/redir.aspx?page=browse&amp;resid=70A5B53D721071B7!499&amp;ct=photos">View Full Album</a></div></div><img src="http://feeds.feedburner.com/~r/OmarBesiso/~4/_c5ecJ5BdJc" height="1" width="1"/>]]></content:encoded>


<category>General</category>

<dc:creator>The Archidev</dc:creator>
<pubDate>Tue, 11 Aug 2009 23:04:47 +1000</pubDate>

<feedburner:origLink>http://omarbesiso.typepad.com/the-archidev/2009/08/parsos-worlds-greatest-shave.html</feedburner:origLink></item>
<item>
<title>SQL 2008 &amp;amp; Sync Framework Over WCF : With Simplicity</title>
<link>http://feedproxy.google.com/~r/OmarBesiso/~3/Viv-x_qDBmE/sql-2008-sync-framework-over-wcf-with-simplicity.html</link>
<guid isPermaLink="false">http://omarbesiso.typepad.com/the-archidev/2009/08/sql-2008-sync-framework-over-wcf-with-simplicity.html</guid>
<description>I am working on a project at the moment that needs to keep a local store of data in order to give it to ability to function when the WCF service that feeds is offline. Once the service is up and running again, the data needs to be synchronized back to the server and any data on the server needs to be synchronized down to the client. This is becoming an increasingly demanded functionality as we see new projects. Now out of the box the Sync Framework will work nicely if you got direct access to SQL. But as the requirement states we have a WCF service sitting between the client and the DB.

In this post I am hoping to show a step by step approach to create a bidirectional synchronization line between a products table on my client and one on my SQL 2008 server that site behind a WCF service. Directly from MSDN this image shows what we try to achieve http://msdn.microsoft.com/en-us/library/bb902831.aspx. 

Note: This is not an entry post of the sync framework. It’s just an explanation how to use sync framework, WCF and SQL 2008. Source code available at the end of the post.



Install the Sync Framework

Please download and install the sync framework found here.

My DB

Nothing fancy to see here, just your good old product table with a couple of rows.





There is a key thing to mention here before I continue. If you are using an SQL Server older than 2008 you will need to be manual change tracking as explained in the link to the MSDN article above. Otherwise SQL 2008 has got built in change tracking features which provide sufficient change tracking information to our scenario. One option in your database you have to make sure is on, is that tracking of changes is enabled. Right Click your database and click properties.



I created a data dude project in my solution for simplicity of distributing the demo’s source code.







My Sync Service – Part 1

The first thing I need to do here is to create a WCF project and add the following dlls as references. This will be my sync service.

Microsoft.Synchronization.dll 
Microsoft.Synchronization.Data.dll 
Microsoft.Synchronization.Data.Server.dll



I then create the following service definition for my Sync Service. These methods (service operations) and their signatures are what my client is going to be expecting when attempting a sync back to the server.

using System.Collections.ObjectModel; using System.Data; using System.Net.Security; using System.ServiceModel; using Microsoft.Synchronization.Data; namespace WcfSyncService { [ServiceContract(Name = "SyncService", SessionMode = SessionMode.NotAllowed, ProtectionLevel = ProtectionLevel.EncryptAndSign)] public interface ISyncService { [OperationContract] SyncContext ApplyChanges(SyncGroupMetadata groupMetadata, DataSet dataSet, SyncSession syncSession); [OperationContract] SyncContext GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession); [OperationContract] SyncSchema GetSchema(Collection&lt;string&gt; tableNames, SyncSession syncSession); [OperationContract] SyncServerInfo GetServerInfo(SyncSession syncSession); } }





My Sync Client – Part 1

Now I come up with a WPF client that displays a list of items from the local cache at any given time. The idea will be to synchronise the local cache with my server’s database through the WCF service we defined earlier. 

So I start off with a simple WPF App.



I now need to add my local cache database.



I now get presented with the following wizard. I choose the server’s connection string and a new client database option is given to me. I then change the project location of the server to my previously created WCF service project. 



From there I choose the products table to create a local dataset. The steps are outlined as follows.





Select the field I want to include in my typed data table.



Viola! Not only did the client create the appropriate cache on the client but it also created the necessary sync providers and adapters in the service project as well.



The thing to note here is that my client is still not configured to sync with the server. For that I will need to do some minor code changes.

My Sync Service – Part 2

Jumping back to the server I need to now implement my service definition. I do that by passing all of the operation on to the Sync provider that has now been created for me by the wizard.

using System.Collections.ObjectModel; using System.Data; using Microsoft.Synchronization.Data; namespace WcfSyncService { public class SyncService : ISyncService { private readonly ProductCacheServerSyncProvider syncProvider; /// &lt;summary&gt; /// Initializes a new instance of the &lt;see cref="SyncService"/&gt; class. /// &lt;/summary&gt; public SyncService() { syncProvider = new ProductCacheServerSyncProvider(); } public SyncContext ApplyChanges(SyncGroupMetadata groupMetadata, DataSet dataSet, SyncSession syncSession) { return syncProvider.ApplyChanges(groupMetadata, dataSet, syncSession); } public SyncContext GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession) { return syncProvider.GetChanges(groupMetadata, syncSession); } public SyncSchema GetSchema(Collection&lt;string&gt; tableNames, SyncSession syncSession) { return syncProvider.GetSchema(tableNames, syncSession); } public SyncServerInfo GetServerInfo(SyncSession syncSession) { return syncProvider.GetServerInfo(syncSession); } } }

My Sync service is now ready to roll and I load in the wcf test client just to make sure everything is alright.



OK so the mental note here is the service does load and it does run but the parameters are not supported by the WCF test client. 

My Sync Client – Part 2

Ok now my WCF service is ready. The next step is to configure the client to use the WCF service for the synchronization. I now add a service reference to my service from the client.





One more thing to note here. The wizard will always create SyncTables with a default SyncDirection of DownloadOnly. But in this scenario we need the table updates to be Bidirectional. The trick is to right click the ProductCache and click on View Code. A partial class is created and you need to modify it as follows.





using Microsoft.Synchronization.Data; namespace WcfSyncClient { public partial class ProductCacheSyncAgent 

{ partial void OnInitialized() { this.Product.SyncDirection = SyncDirection.Bidirectional; } } } 



Ok so now all my infrastructure is ready so time for a semi pretty UI for the display of data and operations.



It’s pretty simple what happens behind these buttons. The main thing to note is that I am instantiating the agent using my WCF client proxy. This basically tells the sync agent to use my WCF service for any synchronisations.

using System; using System.Windows; using Microsoft.Synchronization.Data; using WcfSyncClient.SyncDBDataSetTableAdapters; using WcfSyncClient.SyncServiceProxy; namespace WcfSyncClient { /// &lt;summary&gt; /// Interaction logic for Shell.xaml /// &lt;/summary&gt; public partial class Shell : Window { public Shell() { InitializeComponent(); } private void btnRefresh_Click(object sender, RoutedEventArgs e) { var ds = new SyncDBDataSet(); var adapter = new ProductTableAdapter(); adapter.Fill(ds.Product); listBox.DataContext = ds; } private void btnSynchronise_Click(object sender, RoutedEventArgs e) { var syncAgent = new ProductCacheSyncAgent(new SyncServiceClient()); SyncStatistics syncStats = syncAgent.Synchronize(); } private void btnAddRow_Click(object sender, RoutedEventArgs e) { var ds = (SyncDBDataSet) listBox.DataContext; var dr = ds.Product.NewRow() as SyncDBDataSet.ProductRow; if (dr != null) { dr.Name = "New Product " + (new Random()).Next(); dr.ProductId = Guid.NewGuid(); dr.Price = 800; ds.Product.AddProductRow(dr); var adapter = new ProductTableAdapter(); adapter.Update(ds); } } } }

I can see by running the application the SQL DB is also getting that changes as I add new records on the client and vice versa.





One Problem You Might Run Into

One exception that you might get during debugging your application on 64-bit machines is: 

Unable to load DLL 'sqlceme35.dll': The specified module could not be found.

This is related to the fact that the original release SqlCe was not supported on 64-bit machines. You have two options:

Download Microsoft SQL Server Compact 3.5 Service Pack 1 and Synchronization Services for ADO.NET version 1.0 Service Pack 1 for Windows Desktop 
Compile your project for x86 CPU configuration.

Clearly the first option is the recommended one.

Source Code







Conclusion

The sync framework is a nice tool and toy that simplifies a lot of the hassles we had to go through in the past for offline data caching. Bundling it with WCF just gives it a fantastic edge. It should not be missed in your future projects.</description>
<content:encoded><![CDATA[<p>I am working on a project at the moment that needs to keep a local store of data in order to give it to ability to function when the WCF service that feeds is offline. Once the service is up and running again, the data needs to be synchronized back to the server and any data on the server needs to be synchronized down to the client. This is becoming an increasingly demanded functionality as we see new projects. Now out of the box the Sync Framework will work nicely if you got direct access to SQL. But as the requirement states we have a WCF service sitting between the client and the DB.</p>
<p>In this post I am hoping to show a step by step approach to create a bidirectional synchronization line between a products table on my client and one on my SQL 2008 server that site behind a WCF service. Directly from MSDN this image shows what we try to achieve <a href="http://msdn.microsoft.com/en-us/library/bb902831.aspx">http://msdn.microsoft.com/en-us/library/bb902831.aspx</a>. </p>
<p>Note: This is not an entry post of the sync framework. It’s just an explanation how to use sync framework, WCF and SQL 2008. Source code available at the end of the post.</p>
<h3></h3>
<h3><strong>Install the Sync Framework</strong></h3>
<p>Please download and install the sync framework found <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=C88BA2D1-CEF3-4149-B301-9B056E7FB1E6&amp;displaylang=en" target="_blank">here</a>.</p>
<h3><strong>My DB</strong></h3>
<p>Nothing fancy to see here, just your good old product table with a couple of rows.</p>
<p><a href="https://saakya.bay.livefilestore.com/y1m6WjaC5M-hSJDnZpiAPYDK8cK1-tjXIsHwO2_doLn6ydSPEIlWlO8IosjRU_uY5yoPf9UK_3mVxQwzge_letQUvFG3dO6MGBxKdZwpd4vOtxuG66K0ocFK2YEoPWJL8_mJVvPhjLj6yZU74qRE81KiA/image[10] 27EFB59A.png" rel="WLPP"><img alt="image" border="0" height="115" src="https://saakya.bay.livefilestore.com/y1m5SBA46WtEJ625rVGqtEPZO8pzXW_U9XtFfmcP6rWBozSAIyzllDqxnPiG8OzvUYDG1-Bq0_WQpiC5IlFODnvPpQfH-1tOmczIo-bEbHvT-2tp8mVxUhzUGOwxBbO2-gwtX-xe5sKDvewxeYjYz83Jg/image_thumb[6] 54487419.png" style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" width="479" /></a> </p>
<p><a href="https://saakya.bay.livefilestore.com/y1mi4wpLrpbP_z42Ldt-ZYtrBjFQiY70kwcE6l8LHQ7Qm8NcNaZzjEeeOyw2ufmHtbNTLvoTu9DZOnudZ92FODgbFDWSbyWEq7LSQ_YKqVBjjn6KEEp4TUC0eKvAwGiFu5TfB0mlURF35kgJyyX4qOPzg/image[9] 09611518.png" rel="WLPP"><img alt="image" border="0" height="106" src="https://saakya.bay.livefilestore.com/y1mEizvW9w5mXbJDjGGYIwJsuBe65OmmfPHH3qMMIZaEgBroS2GfOowPFT4tLMzGWf6S-0mI2GPYmtPPiSDAHN-OE1SO3faQFUsTJ-ThEB18pQHumquYyc4U_zQ1w89zpmbjclMSsB8_0e7zEwZAr7kRw/image_thumb[5] 49B3662D.png" style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" width="482" /></a> </p>
<p>There is a key thing to mention here before I continue. If you are using an SQL Server older than 2008 you will need to be manual change tracking as explained in the link to the MSDN article above. Otherwise SQL 2008 has got built in change tracking features which provide sufficient change tracking information to our scenario. One option in your database you have to make sure is on, is that tracking of changes is enabled. Right Click your database and click properties.</p>
<p><a href="https://saakya.bay.livefilestore.com/y1mwhaEdEsCqwHZLQh7IAYDevNGZgX7u0ufdM953ROOMmTZ0yEfm97yN--AUqwk5fJ5buY0EGktZ4Ktl1Iy1phYtSfuN7VuSNFQuY8ZN0hrtP1VZw_tWQ0ZDFBPDWK8bkhBrvOpzNiWGcyQSoCoxPtwqQ/image[95].png" rel="WLPP"><img alt="image" border="0" height="155" src="https://saakya.bay.livefilestore.com/y1m3RGIOCA3lsIQswnlqNBaqBi2ACNASssPLW7FNkJQ3HaJSE1PtfzuiUijol-RjHit3NaPgCQp_WapLMUyiqOPe4lfWUZxbVUppPYYWm1uM6aujN7tMbey0WUXmWDxx3NmnAcA-ffFjw9MmG1EbDkXNw/image_thumb[51].png" style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" width="552" /></a> </p>
<p>I created a data dude project in my solution for simplicity of distributing the demo’s source code.</p>
<p><a href="https://saakya.bay.livefilestore.com/y1m6RCp4WpNAGiEaS5PPHssv6baWLcdDCyxnq9HhHHaIZh5f31nW7Qa68SvNTsB9EudnqKBk3XxWD_5ZuUMf5d0D_o-P128oRDa_YwyqaUFQMLEvpplAKKPfXtnds6jYEXbvm-W6zjRZqXvBmic9ihV2Q/image[14] 187BDDC2.png" rel="WLPP"><img alt="image" border="0" height="63" src="https://saakya.bay.livefilestore.com/y1mMeyIvh2YR_FKPkNOLjWik3ZSKnmzYP1yQykp9MMQKmubCfrM2n1SZInd0AGOtqENWOwQfM9cDWPEz7j_U0AzqjHHe4sJMQDYZz5e8TmV2DFFgy9ITmqPTFes6Ur4PH67bTKInIp37UdC_JuaKb5kgg/image_thumb[8] 751B70F7.png" style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" width="318" /></a>&#0160;</p>
<p></p>
<p></p>
<h3><strong>My Sync Service – Part 1</strong></h3>
<p>The first thing I need to do here is to create a WCF project and add the following dlls as references. This will be my sync service.</p>
<ol>
<li>Microsoft.Synchronization.dll 
<li>Microsoft.Synchronization.Data.dll 
<li>Microsoft.Synchronization.Data.Server.dll </li>
</li></li></ol>
<p><a href="https://saakya.bay.livefilestore.com/y1mk-q10F5Q6cSS_BJ0YFLjTP3hf2ZFmd6cDpksXseZ8SxvKoW8ZRCYxhUcK-m8_jW-lh3zersJY8F92yiu7GDfBQ4pcOCP0Hvj5wTTCM00G5jKjb0Xsbu5hehD5bOQiPoOMbeq1MOECDB4Jc8NxvLwPQ/image[91].png" rel="WLPP"><img alt="image" border="0" height="289" src="https://saakya.bay.livefilestore.com/y1mZKfbNck5KyZLJUpZuQFLTlAU1NnO6ZUcwCfO3RnmxzQIr7os4AQan7oRA0CGJA41QrH9lA9-kO50KJkenUIs9fp9ZcMO9QrMUCPOgjMBSw6hHiFsz9u1XwfCHFNIUnplUnV7bk9pG1Af6QzKF_dhDg/image_thumb[49].png" style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" width="277" /></a> </p>
<p>I then create the following service definition for my Sync Service. These methods (service operations) and their signatures are what my client is going to be expecting when attempting a sync back to the server.</p>
<div style="BORDER-BOTTOM: gray 1px solid; BORDER-LEFT: gray 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: consolas, &#39;Courier New&#39;, courier, monospace; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: gray 1px solid; CURSOR: text; BORDER-RIGHT: gray 1px solid; PADDING-TOP: 4px"><pre style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, &#39;Courier New&#39;, courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><span style="COLOR: #0000ff">using</span> System.Collections.ObjectModel;

<span style="COLOR: #0000ff">using</span> System.Data;

<span style="COLOR: #0000ff">using</span> System.Net.Security;

<span style="COLOR: #0000ff">using</span> System.ServiceModel;

<span style="COLOR: #0000ff">using</span> Microsoft.Synchronization.Data;



<span style="COLOR: #0000ff">namespace</span> WcfSyncService

{

  [ServiceContract(Name = <span style="COLOR: #006080">&quot;SyncService&quot;</span>, SessionMode = SessionMode.NotAllowed,

    ProtectionLevel = ProtectionLevel.EncryptAndSign)]

  <span style="COLOR: #0000ff">public</span> <span style="COLOR: #0000ff">interface</span> ISyncService

  {

    [OperationContract]

    SyncContext ApplyChanges(SyncGroupMetadata groupMetadata, DataSet dataSet, SyncSession syncSession);



    [OperationContract]

    SyncContext GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession);



    [OperationContract]

    SyncSchema GetSchema(Collection&lt;<span style="COLOR: #0000ff">string</span>&gt; tableNames, SyncSession syncSession);



    [OperationContract]

    SyncServerInfo GetServerInfo(SyncSession syncSession);

  }

}</pre></div>
<p></p>
<h3></h3>
<h3><strong>My Sync Client – Part 1</strong></h3>
<p>Now I come up with a WPF client that displays a list of items from the local cache at any given time. The idea will be to synchronise the local cache with my server’s database through the WCF service we defined earlier. </p>
<p>So I start off with a simple WPF App.</p>
<p><a href="https://saakya.bay.livefilestore.com/y1mTqiHims8Q4iBUwQiO_3aQU0zlUJ7ql0mf5HhP44W5O5ptOVl1mWHmsW747lU4R4L45fYgt5c4R_oyR_epgCk6727wBAhEk-CbrlbIy9mFrmdQsyA0Q6MhoOnQoMUsdlFAyGVTeeLoVC8SvBc6MGnCA/image[26].png" rel="WLPP"><img alt="image" border="0" height="197" src="https://saakya.bay.livefilestore.com/y1mqCFt88Zld3-AKZeHCrTSbj2jSJZkg_sEZlXlO9Zbez5N_C2sPEdqFqDL4LjPy45FvyTnN9ZzH95BzuYCiFldiyGsAZTt-nldc7EmWLmTde9zwIIMVRCfbAQnxwPa2yrGA-eBD9D1kY5ss21vcCqVvA/image_thumb[14] 53FF8AB8.png" style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" width="254" /></a> </p>
<p>I now need to add my local cache database.</p>
<p><a href="https://saakya.bay.livefilestore.com/y1mrNUbHPHkShh02SilAi17V-nP4JkL_ZZ_7l6gPrDWRBZqgm2S8Yky4-YlLRcqNhybjJ5SfXF6amxf2G_IL2nXoqn4Lsu9zly9edRatW0V8kNZULARIuYj8YfVn0m95ekwrF7oIiwUwoFcploW7x8bLA/image[64].png" rel="WLPP"><img alt="image" border="0" height="158" src="https://saakya.bay.livefilestore.com/y1m_C9jDGpZr_IPj3u-KVEdTOc-DvJN1zjYpQm5HkguhLotTEW5wQUZkA4qevzL9a0E-TaQRAhE_V4CM3lDfyelKzSfX3Wvr0H3lLP0OGXZyaIJZ9LUCUmSig2gBjEaELzTbDL_ZWyzroXPv1NqF0mFPg/image_thumb[34].png" style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" width="676" /></a> </p>
<p>I now get presented with the following wizard. I choose the server’s connection string and a new client database option is given to me. I then change the project location of the server to my previously created WCF service project. </p>
<p><a href="https://saakya.bay.livefilestore.com/y1mefQcPstXKLOGDjZj6USBDSc_uHZasE_WZxOrQUCA5Jm2asZEhqi0k35D2iW7lV5lpQxA689Rl-4KiV_EgfIdClHq7PbZaQwcP_WdZdMw_K-HfPd56apHKx_w9nU9rQm3_lqsKp2eCUqV3CXUrqVIKA/image[35].png" rel="WLPP"><img alt="image" border="0" height="566" src="https://saakya.bay.livefilestore.com/y1mGa_h2N7LhCP-RaAjhHDV53DKlx2DYOW3miyOUJ1RB3E6gqw8Ne8t4yDUOK4cvviFF1zVmM5m28Hw2MHF1HIbcoHBldN0Qo3yY_XWInrg5L6cW4vK9IdfqJQ9ZnuTyB4JKxmr_MTpQuzleawqY40GXg/image_thumb[19].png" style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" width="785" /></a> </p>
<p>From there I choose the products table to create a local dataset. The steps are outlined as follows.</p>
<p><a href="https://saakya.bay.livefilestore.com/y1mjUZ-cPbyyy_uEBnP0yDWEWHykkxywWpOj6rTlxCy7XtEgVgBmi-4CucUU1W-fM5Dn5qW6zz2DH7uPQmqQaQtnfj9T4OGny5IBO_dJ7htLnv_g3KHv2bFrtvxirgEag55EVBvPlIOJSa56eSx1LZIWg/image[39].png" rel="WLPP"><img alt="image" border="0" height="519" src="https://saakya.bay.livefilestore.com/y1mUj3SPgfMRq3g9KJA5Ha1f0N4zHXSJh5vh3owxXWI-YnoJ_v-ykwMFUmsbElK85rQV-ZT_YilFtL3NC3ntluj-VP13gS0qiX4hQBCOVjXlPwE__owXmCw65aOXwcKEGvCYZQQnT9YZC5JWUA_9uJIGg/image_thumb[21].png" style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" width="791" /></a> </p>
<p>&#0160;<a href="https://saakya.bay.livefilestore.com/y1mW7jcnNN5OnbKxFkuk_6EXxlcRcNHG8t_n2_CCxmKHGk6sQ-606pAsS7iet4lVrBRZQQUwamsKFOAPotfBFOdnZCdZFbQk_BcM98cbstnmyRHMJcfMDpx3kY96H4oe0DAyqzFXUCt4sqZNIvGJxaLFw/image[44].png" rel="WLPP"><img alt="image" border="0" height="478" src="https://saakya.bay.livefilestore.com/y1mFs9eJUNCIfu1OWn_DkwmQ8SEr3A5F64sLApGOGS0BMpAteFiyETjjjq1_H-6hbTaEtBiANqkke0iBzbjM-ftfcm5g_HLSV99giSsoP28J673K3Sqg5t6yum-l--u_5_gLQ3qOR43nAYB4P0Cm5xx7g/image_thumb[24].png" style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" width="777" /></a></p>
<p>Select the field I want to include in my typed data table.</p>
<p><a href="https://saakya.bay.livefilestore.com/y1m2hLsMyhtc_cJWpr6yB-1DIXwbbzUgwqve9MoYCruvZTQbyHp3qWVxTvTwtToruc7woszNnM-AgIN1QesesdkhKpjUgIV8crBr3NcWTckHWfC8VX54xAU6geA7yUvUWavCjR_m6TyMgdCliVNPAT__A/image[49].png" rel="WLPP"><img alt="image" border="0" height="599" src="https://saakya.bay.livefilestore.com/y1mGjP0i2h0y0jE5zIJQLKco8xnmKSF3ULZM-ziV7nl15HpeRxOdet7fqhOs2viCXD4eAN9jLw7SOVhUrGZYomw29m2dHaEgzebdOlm5QpZ1NzgQrzkR2r3SSuw-dwHm-OnZgjRa3eHAN59I2gLJb_usQ/image_thumb[27].png" style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" width="776" /></a> </p>
<p>Viola! Not only did the client create the appropriate cache on the client but it also created the necessary sync providers and adapters in the service project as well.</p>
<p><a href="https://saakya.bay.livefilestore.com/y1m0DE2uWcoRPj9UaVso_64uH1YU0_EpAlpHpuWKWykWjuuNU05r1RcpEMPpGDbYYcYB_L-bwuEMtBHBpG-1E-dY8rKOZnsERS2erWCJnBdx0XK3gNu6iDFrE6tyhyW63M79EvJtatY6Nz_CdQpWzUkyw/image[68].png" rel="WLPP"><img alt="image" border="0" height="448" src="https://saakya.bay.livefilestore.com/y1mBUw76GZPMifOEyrmbZKHiqoOpZ7bMBqpocbBBxYDDPv2bQrSmGVlT0HhueHLeVy2MXJ0-yIWwYZ6UXWwmn3r0PqF7mMzGWlKIpwTn85Dx6MeDkqsFiiRMmM2-vHO86yevF4QKx4QZZUCtTSE3cVnow/image_thumb[36].png" style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" width="344" /></a> </p>
<p>The thing to note here is that my client is still not configured to sync with the server. For that I will need to do some minor code changes.</p>
<h3><strong>My Sync Service – Part 2</strong></h3>
<p>Jumping back to the server I need to now implement my service definition. I do that by passing all of the operation on to the Sync provider that has now been created for me by the wizard.</p>
<div style="BORDER-BOTTOM: gray 1px solid; BORDER-LEFT: gray 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: consolas, &#39;Courier New&#39;, courier, monospace; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: gray 1px solid; CURSOR: text; BORDER-RIGHT: gray 1px solid; PADDING-TOP: 4px"><pre style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, &#39;Courier New&#39;, courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><span style="COLOR: #0000ff">using</span> System.Collections.ObjectModel;

<span style="COLOR: #0000ff">using</span> System.Data;

<span style="COLOR: #0000ff">using</span> Microsoft.Synchronization.Data;



<span style="COLOR: #0000ff">namespace</span> WcfSyncService

{

  <span style="COLOR: #0000ff">public</span> <span style="COLOR: #0000ff">class</span> SyncService : ISyncService

  {

    <span style="COLOR: #0000ff">private</span> <span style="COLOR: #0000ff">readonly</span> ProductCacheServerSyncProvider syncProvider;



    <span style="COLOR: #008000">/// &lt;summary&gt;</span>

    <span style="COLOR: #008000">/// Initializes a new instance of the &lt;see cref=&quot;SyncService&quot;/&gt; class.</span>

    <span style="COLOR: #008000">/// &lt;/summary&gt;</span>

    <span style="COLOR: #0000ff">public</span> SyncService()

    {

      syncProvider = <span style="COLOR: #0000ff">new</span> ProductCacheServerSyncProvider();

    }



    <span style="COLOR: #0000ff">public</span> SyncContext ApplyChanges(SyncGroupMetadata groupMetadata, DataSet dataSet, SyncSession syncSession)

    {

      <span style="COLOR: #0000ff">return</span> syncProvider.ApplyChanges(groupMetadata, dataSet, syncSession);

    }



    <span style="COLOR: #0000ff">public</span> SyncContext GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession)

    {

      <span style="COLOR: #0000ff">return</span> syncProvider.GetChanges(groupMetadata, syncSession);

    }



    <span style="COLOR: #0000ff">public</span> SyncSchema GetSchema(Collection&lt;<span style="COLOR: #0000ff">string</span>&gt; tableNames, SyncSession syncSession)

    {

      <span style="COLOR: #0000ff">return</span> syncProvider.GetSchema(tableNames, syncSession);

    }



    <span style="COLOR: #0000ff">public</span> SyncServerInfo GetServerInfo(SyncSession syncSession)

    {

      <span style="COLOR: #0000ff">return</span> syncProvider.GetServerInfo(syncSession);

    }

  }

}</pre></div>
<p>My Sync service is now ready to roll and I load in the wcf test client just to make sure everything is alright.</p>
<p><a href="https://saakya.bay.livefilestore.com/y1mzfgYcrIeKeqGZoigA-hCI6DoSGTJ2UJUEErKrBfbHyI6iNhQmquW-7T-O_O7PJWnLBRrc9SlvtAs_8ia9oR_qUGUHecH1y5gSI6q97cncMcEgXOiqMdE-gNXmwUe1kP_6GqBOfoBBcT_CpD7FBKBuw/image[18].png" rel="WLPP"><img alt="image" border="0" height="331" src="https://saakya.bay.livefilestore.com/y1mO0dPjk4U005Q9VvI_EJY40YBzxQokshfoNGZPnuufaLYN6B4CTZwWe-jlubWQEDAJzcVSvZmCNLcyTj_pfjCG0u7nkeHA9irtBDAKRM5MRzCp-7BgcPepzRFN-Cit9gRThhXm2svpesEqwto6-otxg/image_thumb[10] 477803BF.png" style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" width="448" /></a> </p>
<p>OK so the mental note here is the service does load and it does run but the parameters are not supported by the WCF test client. </p>
<h3><strong>My Sync Client – Part 2</strong></h3>
<p>Ok now my WCF service is ready. The next step is to configure the client to use the WCF service for the synchronization. I now add a service reference to my service from the client.</p>
<p><a href="https://saakya.bay.livefilestore.com/y1maoiOUsJn22CcmrrdZuZZs2fK0x0JJY18zfSIm6-y9a5yU85ggiGnMHBqyILXkVuYUfyrLHGd0YmDv5VS7yt_m8uW56Gfgm4-SCzQzciqZqJqYdmbsjAnCRB62oXZqYyYDwb5ZtRNegQnqRUP3EAR4Q/image[74].png" rel="WLPP"><img alt="image" border="0" height="494" src="https://saakya.bay.livefilestore.com/y1mlDTG_yDrCY5wQyMEzgAVRmJez6B5-ibkdsqTlHaX622ksBMUWoiwfQbXwuT6alvTQI3iyzoLTx09yqUkPhfofU2HwVUR9xFguj62NNHXBQg1HGxK0GHhkMotYrBxQU5drZLHpIiqTtEzMFJdAbazSQ/image_thumb[40].png" style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" width="620" /></a> </p>
<p><a href="https://saakya.bay.livefilestore.com/y1m3TpIHCVRT7UwDyNr-bwaST8Hh0GqBbSSkaom1KD_IGxncTZOY1y_8g0ELRL5EaNhZq5c7bnzCADPa7VLG7P2TAGPEukNpLp-sWYFP09P1-wNQouOf7dJE1Muim8x0SchO64WLaKJ_MIOQLmOxPqiPQ/image[78].png" rel="WLPP"><img alt="image" border="0" height="346" src="https://saakya.bay.livefilestore.com/y1mW-d0BjDA5HRr_e2rfgo-JYOk-PybyQ9Qh5Yz6MIIBAoaH4haqoYtGfN9RSChp8bqoe3qzKZx1iN4NHfga-1Ltn6EotLl_7CtuBuZSp23DUPyXkgYodhpt50At9b-Zu665gqnBkyCGQm80yOyZs6C4g/image_thumb[42].png" style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" width="379" /></a> </p>
<p>One more thing to note here. The wizard will always create SyncTables with a default SyncDirection of DownloadOnly. But in this scenario we need the table updates to be Bidirectional.&#0160; The trick is to right click the ProductCache and click on View Code. A partial class is created and you need to modify it as follows.</p>
<p><a href="https://saakya.bay.livefilestore.com/y1mEGzMqi832-g_FTxnrXk2yhA6H47oIwopu0y-D8J7Lq7nl9dRqSstML45HPuL_B05NivD41boyFUsX4ZFajpilwTc0TC48WyGy_y8HtkJ6hBdEpxr27UVHfAcoFs1h2nsKiQq-5lDDjRPO1YAfnUECQ/image[81].png" rel="WLPP"><img alt="image" border="0" height="71" src="https://saakya.bay.livefilestore.com/y1mXESVJ8UqmqEy4SZ3wNfDOyADbtfM0rG9k8P-s1f47ixpuY5_Nu2-Pwzo-cR3wxLfl0YTlldJa1ABVn6ctwLPp8NB0Apxag5hgbJ-hv-7Sek0B_GsnYlNbnGPLXcV1IITtkZ7wwHARh2gRmMl5U-JAQ/image_thumb[43].png" style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" width="238" /></a> </p>
<div style="BORDER-BOTTOM: gray 1px solid; BORDER-LEFT: gray 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: consolas, &#39;Courier New&#39;, courier, monospace; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: gray 1px solid; CURSOR: text; BORDER-RIGHT: gray 1px solid; PADDING-TOP: 4px"><pre style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, &#39;Courier New&#39;, courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><p><span style="COLOR: #0000ff">using</span> Microsoft.Synchronization.Data;



<span style="COLOR: #0000ff">namespace</span> WcfSyncClient {

  

  

  <span style="COLOR: #0000ff">public</span> <span style="COLOR: #0000ff">partial</span> <span style="COLOR: #0000ff">class</span> ProductCacheSyncAgent </p><p>{

    

    <span style="COLOR: #0000ff">partial</span> <span style="COLOR: #0000ff">void</span> OnInitialized()

    {

      <span style="COLOR: #0000ff">this</span>.Product.SyncDirection = SyncDirection.Bidirectional;

    }

  }

}

</p></pre></div>
<p>Ok so now all my infrastructure is ready so time for a semi pretty UI for the display of data and operations.</p>
<p><a href="https://saakya.bay.livefilestore.com/y1m4cqKFEaRWQIembp6u93l27D_0c2zVYWFgH6b_M805EGzp7Oqn-j93YhbBION0Z3Ipz7Hgh1xiWGZm4KBILXCiDGd7bskZ3CJU40vtWCFCD0gzGJI0xHg2_38dQ2_s_L96dB1qfinIG3GbhfSF8Pefw/image[86].png" rel="WLPP"><img alt="image" border="0" height="465" src="https://saakya.bay.livefilestore.com/y1mw6rDkDZyvPYU0e00cqOOZwmF07brKnah0v1X48EqthV-CudpYB2r8lwlNHL5FrEJ05aPC-ljkMqYVTUp4VoHGqKJG-lJq7vR0SJdfx1q46-t4b0xKKrMIuQ24do7nF16pxx-12LC4Dx58vkgtiKgMA/image_thumb[46].png" style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" width="732" /></a> </p>
<p>It’s pretty simple what happens behind these buttons. The main thing to note is that I am instantiating the agent using my WCF client proxy. This basically tells the sync agent to use my WCF service for any synchronisations.</p>
<div style="BORDER-BOTTOM: gray 1px solid; BORDER-LEFT: gray 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: consolas, &#39;Courier New&#39;, courier, monospace; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: gray 1px solid; CURSOR: text; BORDER-RIGHT: gray 1px solid; PADDING-TOP: 4px"><pre style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, &#39;Courier New&#39;, courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><span style="COLOR: #0000ff">using</span> System;

<span style="COLOR: #0000ff">using</span> System.Windows;

<span style="COLOR: #0000ff">using</span> Microsoft.Synchronization.Data;

<span style="COLOR: #0000ff">using</span> WcfSyncClient.SyncDBDataSetTableAdapters;

<span style="COLOR: #0000ff">using</span> WcfSyncClient.SyncServiceProxy;



<span style="COLOR: #0000ff">namespace</span> WcfSyncClient

{

  <span style="COLOR: #008000">/// &lt;summary&gt;</span>

  <span style="COLOR: #008000">/// Interaction logic for Shell.xaml</span>

  <span style="COLOR: #008000">/// &lt;/summary&gt;</span>

  <span style="COLOR: #0000ff">public</span> <span style="COLOR: #0000ff">partial</span> <span style="COLOR: #0000ff">class</span> Shell : Window

  {

    <span style="COLOR: #0000ff">public</span> Shell()

    {

      InitializeComponent();

    }



    <span style="COLOR: #0000ff">private</span> <span style="COLOR: #0000ff">void</span> btnRefresh_Click(<span style="COLOR: #0000ff">object</span> sender, RoutedEventArgs e)

    {

      var ds = <span style="COLOR: #0000ff">new</span> SyncDBDataSet();

      var adapter = <span style="COLOR: #0000ff">new</span> ProductTableAdapter();

      adapter.Fill(ds.Product);

      listBox.DataContext = ds;

    }



    <span style="COLOR: #0000ff">private</span> <span style="COLOR: #0000ff">void</span> btnSynchronise_Click(<span style="COLOR: #0000ff">object</span> sender, RoutedEventArgs e)

    {

      var syncAgent = <span style="COLOR: #0000ff">new</span> ProductCacheSyncAgent(<span style="COLOR: #0000ff">new</span> SyncServiceClient());

      SyncStatistics syncStats = syncAgent.Synchronize();

    }



    <span style="COLOR: #0000ff">private</span> <span style="COLOR: #0000ff">void</span> btnAddRow_Click(<span style="COLOR: #0000ff">object</span> sender, RoutedEventArgs e)

    {

      var ds = (SyncDBDataSet) listBox.DataContext;

      var dr = ds.Product.NewRow() <span style="COLOR: #0000ff">as</span> SyncDBDataSet.ProductRow;

      <span style="COLOR: #0000ff">if</span> (dr != <span style="COLOR: #0000ff">null</span>)

      {

        dr.Name = <span style="COLOR: #006080">&quot;New Product &quot;</span> + (<span style="COLOR: #0000ff">new</span> Random()).Next();

        dr.ProductId = Guid.NewGuid();

        dr.Price = 800;

        ds.Product.AddProductRow(dr);



        var adapter = <span style="COLOR: #0000ff">new</span> ProductTableAdapter();

        adapter.Update(ds);

      }

    }

  }

}</pre></div>
<p>I can see by running the application the SQL DB is also getting that changes as I add new records on the client and vice versa.</p>
<p><a href="https://saakya.bay.livefilestore.com/y1m89ZHMIGFRJbn7R89-d_ar3O2Z3t1Dg-ggqDhkkbf1OAuGVwJHpgFJ83TtB0ohD646yVSHBURVdEinLOXrgBoPP9z49rwrg_6KbVn9tFATI3y_hg9mNTIi1sRsGZu7OUMimYWFkWJs19jYDRX2Rcx4w/image[96].png" rel="WLPP"><img alt="image" border="0" height="195" src="https://saakya.bay.livefilestore.com/y1mGbZ5F0jCWOgqiPsTO_aU8NoQ3H7F1QMcTHmOI_ddxjAKzv3NHskDcbM65sNbd43GzBEeVxRffTTqcNVbkb0mlV36JBoSuvU7-gMdq73GXqIixoigiZs7aqVzvyPxQvDyOyR_aFCwonu2io1eit00Kw/image_thumb[52].png" style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" width="512" /></a> </p>
<h3></h3>
<h3><strong>One Problem You Might Run Into</strong></h3>
<p>One exception that you might get during debugging your application on 64-bit machines is: </p>
<p><strong>Unable to load DLL &#39;sqlceme35.dll&#39;: The specified module could not be found.</strong></p>
<p>This is related to the fact that the original release SqlCe was not supported on 64-bit machines. You have two options:</p>
<ol>
<li>Download <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=DC614AEE-7E1C-4881-9C32-3A6CE53384D9&amp;displaylang=en#filelist" target="_blank">Microsoft SQL Server Compact 3.5 Service Pack 1 and Synchronization Services for ADO.NET version 1.0 Service Pack 1 for Windows Desktop</a> 
<li>Compile your project for x86 CPU configuration. </li>
</li></ol>
<p>Clearly the first option is the recommended one.</p>
<h3><strong>Source Code</strong></h3><iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-70a5b53d721071b7.skydrive.live.com/embedrowdetail.aspx/Public/Source Code/WCFSyncFramework.zip" style="BORDER-BOTTOM: #dde5e9 1px solid; BORDER-LEFT: #dde5e9 1px solid; PADDING-BOTTOM: 0px; BACKGROUND-COLOR: #ffffff; MARGIN: 3px; PADDING-LEFT: 0px; WIDTH: 240px; PADDING-RIGHT: 0px; HEIGHT: 66px; BORDER-TOP: #dde5e9 1px solid; BORDER-RIGHT: #dde5e9 1px solid; PADDING-TOP: 0px"></iframe>
<h3></h3>
<h3></h3>
<h3><strong>Conclusion</strong></h3>
<p>The sync framework is a nice tool and toy that simplifies a lot of the hassles we had to go through in the past for offline data caching. Bundling it with WCF just gives it a fantastic edge. It should not be missed in your future projects.</p><img src="http://feeds.feedburner.com/~r/OmarBesiso/~4/Viv-x_qDBmE" height="1" width="1"/>]]></content:encoded>


<category>SQL</category>

<dc:creator>The Archidev</dc:creator>
<pubDate>Tue, 11 Aug 2009 23:02:49 +1000</pubDate>

<feedburner:origLink>http://omarbesiso.typepad.com/the-archidev/2009/08/sql-2008-sync-framework-over-wcf-with-simplicity.html</feedburner:origLink></item>

</channel>
</rss><!-- ph=1 -->

