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

<channel>
	<title>Udi Dahan - The Software Simplist &#187; Smart Client</title>
	<atom:link href="http://www.udidahan.com/category/smart-client/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.udidahan.com</link>
	<description>Enterprise Development Expert &#38; SOA Specialist</description>
	<lastBuildDate>Sun, 08 Jan 2012 12:45:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MSDN Magazine Smart Client Article</title>
		<link>http://www.udidahan.com/2009/03/28/msdn-magazine-smart-client-article/</link>
		<comments>http://www.udidahan.com/2009/03/28/msdn-magazine-smart-client-article/#comments</comments>
		<pubDate>Sat, 28 Mar 2009 19:16:39 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[ESB]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Pub/Sub]]></category>
		<category><![CDATA[Scalability]]></category>
		<category><![CDATA[Smart Client]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://www.udidahan.com/2009/03/28/msdn-magazine-smart-client-article/</guid>
		<description><![CDATA[
My article on “optimizing a large-scale Software+Services application” has been published in the April edition of MSDN Magazine.
Here’s a short excerpt:
“We had to juggle occasional connectivity, data synchronization, and publish/subscribe all at the same time. We learned that we couldn’t solve all problems either client-side or server-side, but rather that an integrated approach was needed [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://msdn.microsoft.com/en-us/magazine/dd569749.aspx"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; margin: 0px 0px 10px 10px; border-left: 0px; border-bottom: 0px" height="244" alt="image" src="http://www.udidahan.com/wp-content/uploads/MSDNMagazineSmartClientArticle_13E17/image.png" width="189" align="right" border="0" /></a></p>
<p>My article on “optimizing a large-scale Software+Services application” has been published in the April edition of MSDN Magazine.</p>
<p>Here’s a short excerpt:</p>
<blockquote><p>“We had to juggle occasional connectivity, data synchronization, and publish/subscribe all at the same time. We learned that we couldn’t solve all problems either client-side or server-side, but rather that an integrated approach was needed since any changes on one side needed corresponding changes on the other side.”</p></blockquote>
<p><a href="http://msdn.microsoft.com/en-us/magazine/dd569749.aspx">Continue reading… </a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2009/03/28/msdn-magazine-smart-client-article/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Command Query Separation and SOA</title>
		<link>http://www.udidahan.com/2008/08/11/command-query-separation-and-soa/</link>
		<comments>http://www.udidahan.com/2008/08/11/command-query-separation-and-soa/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 13:18:40 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Autonomous Services]]></category>
		<category><![CDATA[Messaging]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Pub/Sub]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Smart Client]]></category>

		<guid isPermaLink="false">http://www.udidahan.com/2008/08/11/command-query-separation-and-soa/</guid>
		<description><![CDATA[One of the common questions I receive from people starting to use nServiceBus is how one-way messaging fits with showing the user a grid (or list) of data. Thinking about publish/subscribe usually just gets them even more confused. Trying to resolve all this with Service Oriented Architecture leaves them wondering &#8211; why bother?

In regular client-server [...]]]></description>
			<content:encoded><![CDATA[<p>One of the common questions I receive from people starting to use nServiceBus is how one-way messaging fits with showing the user a grid (or list) of data. Thinking about publish/subscribe usually just gets them even more confused. Trying to resolve all this with Service Oriented Architecture leaves them wondering &#8211; why bother?</p>
<p><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="267" alt="client server" src="http://www.udidahan.com/wp-content/uploads/image38.png" width="477" border="0" /></p>
<p>In regular client-server development, the server is responsible for providing the client with all CRUD (create, read, update, and delete) capabilities. However, when users look at data they do not often require it to be up to date to the second (given that they often look at the same screen for several seconds to minutes at a time). As such, retrieving data from the same table as that being used for highly consistent transaction processing creates contention resulting in poor performance for all CRUD actions under higher load.</p>
<h4>A Scalable Solution </h4>
<p>One of the common answers to this question is for the server/service to publish a message when data changes (say, as the result of processing a message) and for clients to subscribe to these messages. When such a notification arrives at a client, the client would cache the data it needs. Then, when the user wants to see a grid of data, that data is already on the client. Of course, this solution doesn&#8217;t work so well for older client machines (like some point of service devices) or if there are millions of rows of data.</p>
<p>The thing is that this solution is one implementation of a more general pattern &#8211; command query separation (CQS).</p>
<h4>Command Query Separation</h4>
<p>Wikipedia <a href="http://en.wikipedia.org/wiki/Command-query_separation">describes</a> CQS as a pattern where &quot;&#8230; every method should either be a <i>command</i> that performs an action, or a <i>query</i> that returns data to the caller, but not both. More formally, methods should return a value only if they are referentially transparent and hence possess no side effects.&quot;</p>
<p>Martin Fowler is less strict about the use of CQS <a href="http://martinfowler.com/bliki/CommandQuerySeparation.html">allowing for exceptions</a>: &quot;Popping a stack is a good example of a modifier that modifies state. Meyer correctly says that you can avoid having this method, but it is a useful idiom. So I prefer to follow this principle when I can, but I&#8217;m prepared to break it to get my pop.&quot;</p>
<p>So, how does separating commands from queries and SOA help at all in getting data to and from a UI? The answer is based on Pat Helland&#8217;s thinking as described in his article <a href="http://msdn.microsoft.com/en-us/library/ms954587.aspx">Data on the Inside vs. Data on the Outside</a>.</p>
<h4>Services Cross Boxes </h4>
<p>The biggest lie around SOA is that services run.</p>
<p>Let that sink in a second.</p>
<p>Sure services have runnable components, but that&#8217;s not why they&#8217;re important. </p>
<p>I&#8217;ll skip the <a href="http://www.udidahan.com/first-time-here/#soa">books of background</a> and cut to the chase:</p>
<blockquote><p>Services communicate with each other using publish/subscribe and one-way messaging. Services have components inside them. Inside a service, these components can communicate with each using synchronous RPC, or any other mechanism. Also, <em>these components can reside on different machines</em>.</p>
</blockquote>
<p>This is broader than just scaling out a service. There can be service components running on the client as well as the server.</p>
<h4>SOA &amp; CQS</h4>
<p>Combining these two concepts together, here&#8217;s what comes out:</p>
<p><img src="http://www.nservicebus.com/img/CQS.png" /> </p>
<p>In this solution there are two services that span both client and server &#8211; one in charge of commands (create, update, delete), the other in charge of queries (read). These services communicate only via messages &#8211; one cannot access the database of the other. </p>
<p>The command service publishes messages about changes to data, to which the query service subscribes. When the query service receives such notifications, it saves the data in its own data store which may well have a different schema (optimized for queries like a star schema).</p>
<p>The client component which is in charge of showing grids of data to the user behaves the same as it would in a regular layered/tiered architecture, using synchronous blocking request/response to get its data &#8211; SOA doesn&#8217;t change that.</p>
<h4>Composite Applications </h4>
<p>Although the client side components of both the command and query services are hosted in the same process, they are very much independent of each other. That being said, from an interoperability perspective (the one that most people attribute to SOA), all of the client-side components will likely be developed using the same technology &#8211; although there are already ways to <a href="http://www.udidahan.com/2007/05/28/netjava-interop-is-not-a-reason-for-soa/">host Java code in .NET</a> and vice-versa. </p>
<p>Of course, once we talk about web UI&#8217;s things are a bit different &#8211; but still similar. While web-server-side there may be a level of independence, for browser side inter-component communications we&#8217;re still likely to target javascript. There, I&#8217;ve managed to say something technical supporting mashups and SOA without lying through my teeth.</p>
<p>On the Microsoft side with the recent release of the Composite Application Guidance &amp; Library (pronounced &quot;<a href="http://www.codeplex.com/CompositeWPF">prism</a>&quot;) I hope that more of these principles will be reaching the &quot;smart client&quot;. The command pattern is especially critical in maintaining the separation while enabling communication to still occur so I&#8217;m glad that, as one of the Prism advisors, I was able to simplify that part (<a href="http://codebetter.com/blogs/glenn.block/">Glenn</a> still has nightmares about that rooftop conversation).</p>
<h4>Publish / Subscribe</h4>
<p>In the &quot;scalable solution&quot; section up top I mentioned how publish/subscribe to the smart client is really just one implementation of CQS and SOA. So, how different is it really?</p>
<p><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="241" alt="smart client pub/sub" src="http://www.udidahan.com/wp-content/uploads/image39.png" width="554" border="0" /> </p>
<p>Well, there will probably be a different technology mapping. Instead of a star-schema OLAP product, we might simply store the published data in memory on the client. That is, if you designed your components to be technology agnostic.</p>
<p>In terms of the use of nServiceBus, the same component is going to be subscribing to the same type of message &#8211; all that&#8217;s different is that now every client will be having data pushed to them rather than this occurring server-side only. </p>
<p>You could have the same code deployed differently in the same system &#8211; stronger clients subscribing themselves, weaker ones using a remote server. Web servers would probably be considered stronger clients. This kind of flexible deployment has proven to be extremely valuable for my larger clients. The added benefit of enabling users to work (view data) even while offline (somewhere there&#8217;s no WIFI) is just icing on the cake.</p>
<h4>A Word of Warning</h4>
<p>Once the client starts receiving notifications, and handling those on a background thread (as it should) the code becomes susceptible to deadlocks and data races. Juval does a good job of outlining <a href="http://www.udidahan.com/2008/04/11/wcf-smart-clients-and-deadlocks/">some of those</a> with respect to the use of WCF. Prism <a href="http://www.udidahan.com/2008/06/09/prism-occasionally-connected/">doesn&#8217;t provide any assurances</a> in this area either.</p>
<h4>Summary</h4>
<p>NServiceBus is not designed to be used for any and all types of communication in a given architecture. In the examples above, nServiceBus handles the publish/subscribe but leaves the synchronous RPC to existing solutions like WCF. Not only that, but synchronous RPC does have its place in architecture, just not across service boundaries. In all cases, data is served to users from a store different from that which transaction processing logic uses.</p>
<p>Command Query Separation is not only a good idea at the method/class level but has advantages at the SOA/System level as well &#8211; yet another good idea from 20 years ago that services build upon. Making use of CQS requires understanding your data and its uses &#8211; SOA builds on that by looking into data volatility and the freshness business requirements around it.</p>
<p>Finally, designing the components of your services in such a way that their dependency on technology is limited buys a lot of flexibility in terms of deployment and, consequently, significant performance and scalability gains.</p>
<p>Simple, it is. Easy, it is not.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2008/08/11/command-query-separation-and-soa/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Prism &#8211; Occasionally Connected?</title>
		<link>http://www.udidahan.com/2008/06/09/prism-occasionally-connected/</link>
		<comments>http://www.udidahan.com/2008/06/09/prism-occasionally-connected/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 12:46:56 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Smart Client]]></category>
		<category><![CDATA[Threading]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/06/09/prism-occasionally-connected/</guid>
		<description><![CDATA[Prism, AKA Composite Application Guidance + Composite Application Library, is rolling towards a release. I&#8217;ve been talking with Glenn Block quite a bit about Prism, and am even on the advisory board (what were they thinking?).
One of the topics not covered by Prism is occasional connectivity, and I would like to say a word or [...]]]></description>
			<content:encoded><![CDATA[<p>Prism, AKA Composite Application Guidance + Composite Application Library, is rolling towards a release. I&#8217;ve been talking with Glenn Block quite a bit about Prism, and am even on the advisory board (what were they thinking?).</p>
<p>One of the topics <em>not</em> covered by Prism is occasional connectivity, and I would like to say a word or two about that. First of all, if you&#8217;re building a standalone client (one that doesn&#8217;t communicate with anything), then there&#8217;s a good chance that Prism isn&#8217;t for you, although you could be composing other standalone client modules. So, if your client isn&#8217;t communicating with anything, well, then this post probably won&#8217;t interest you that much. Let&#8217;s start with&#8230;</p>
<h3>Physics<img style="border-right: 0px; border-top: 0px; margin: 0px 0px 10px 10px; border-left: 0px; border-bottom: 0px" height="192" alt="Physics" src="http://udidahan.weblogs.us/wp-content/uploads/image22.png" width="244" align="right" border="0"> </h3>
<p>Networks fail. Period. </p>
<p>This means that your client machine will not always be connected to other servers. </p>
<p>Also, servers fail &#8211; critical Windows patches and just regular power outages.</p>
<blockquote><p>Ergo, your &#8220;smart&#8221; client will be occasionally connected, whether you planned for it or not.</p>
</blockquote>
<p>And please don&#8217;t take this post as a &#8220;dumping on Prism&#8221; post &#8211; it isn&#8217;t intended that way. Rather, it is about how you should think about designing modules in Prism, and why.</p>
<h3>Modules and Connectivity</h3>
<p>Consider the case where we have two modules being composed in a single client. Each module communicates with a different server. Let&#8217;s call these modules Ma and Mb, and the servers Sa and Sb respectively. Now, let&#8217;s discuss what occurs given that the modules weren&#8217;t designed with occasional connectivity in mind.</p>
<blockquote><p>User clicks something in Mb which requires communication.</p>
<p>Mb tries to call Sb, say, over HTTP, using a regular web service invocation.</p>
<p>The calling thread, in this case, the one used for user interaction, is blocked waiting for a response from Sb.<a href="http://udidahan.weblogs.us/wp-content/uploads/image23.png"><img style="border-right: 0px; border-top: 0px; margin: 10px 0px 10px 10px; border-left: 0px; border-bottom: 0px" height="184" alt="image" src="http://udidahan.weblogs.us/wp-content/uploads/image-thumb19.png" width="244" align="right" border="0"></a></p>
<p>Sometime in this call, Sb fails, connectivity goes down, whatever. </p>
<p>30 seconds after the call, the HTTP connection times out.</p>
</blockquote>
<p>If something important were happening in Ma at the same time, the user couldn&#8217;t even <em>see</em> it, let alone do anything about it since the user interaction thread is stuck. This is a serious concern for the financial services domain, but in many others as well.</p>
<h3>You mean there&#8217;s more?</h3>
<p>I can go on, but I think that that&#8217;s enough to paint the picture that if you are building a smart client, there are a lot more things to think about than just learning Prism. That&#8217;s my main concern after witnessing what happened around the CAB. Given the learning curve around these frameworks many developers don&#8217;t seek to deepen their understanding beyond just becoming proficient with them. This isn&#8217;t just centered on the developers, evangelists in Microsoft tend to paint the picture this way:</p>
<blockquote><p>Once you understand X (CAB, Prism, BizTalk, whatever), all your problems are solved.</p>
</blockquote>
<p>That&#8217;s not to say there aren&#8217;t good things in those technologies, but that&#8217;s just it, they&#8217;re just <em>tools</em>. Silver hammers and &#8220;laser&#8221; guided saws do not a master carpenter make. There&#8217;s actually a pretty good chance the regular guy will saw their arm off.</p>
<h3>Help<a href="http://udidahan.weblogs.us/wp-content/uploads/image24.png"><img style="border-right: 0px; border-top: 0px; margin: 10px 0px 10px 10px; border-left: 0px; border-bottom: 0px" height="191" alt="image" src="http://udidahan.weblogs.us/wp-content/uploads/image-thumb20.png" width="244" align="right" border="0"></a></h3>
<p>I do hope more &#8220;instruction manuals&#8221; will be coming out of Microsoft on these topics. That&#8217;s not to say there aren&#8217;t any. Specifically on the topic of occasional connectivity, there is <a href="http://msdn.microsoft.com/en-us/library/ms998482.aspx">Chapter 4 of the Smart Client Architecture &amp; Design Guide</a>. Unfortunately, it doesn&#8217;t say anything about how that connects with the MVC/MVP being used client side (the bits affected by Prism). <a href="http://msdn.microsoft.com/en-us/library/ms998490.aspx">Chapter 6</a> of the same guide deals with the client-side threading, but doesn&#8217;t address issues like: </p>
<ul>
<li>Which model object instance are views bound to.</li>
<li>Do other threads have access to that object at the same time.</li>
<li>Which controller/presenter is responsible for giving that object to the view.</li>
<li>Do they need to clone it.</li>
<li>How deep should the clone be.</li>
<li>How do various controllers/presenters (which may be showing the same object in different views at the same time) communicate changes to their various independent clones.</li>
</ul>
<p>I haven&#8217;t yet documented all the patterns that answer these questions, but until I do (or Microsoft does), let me offer these few resources which I&#8217;ve put out over the years:</p>
<ul>
<li><a href="http://www.developer.com/design/article.php/3708006">Occasionally Connected Systems Architecture: The Client</a></li>
<li><a href="http://www.developer.com/design/article.php/3705396">Occasionally Connected Systems Architecture: Concurrency</a></li>
<li><a href="http://www.developer.com/design/article.php/3708006">Threading issues when smart clients reconnect</a></li>
<li>[Podcast] <a href="http://udidahan.weblogs.us/2007/04/17/podcast-occasionally-connected-smart-clients-and-adonet-sync-services/">Occasionally Connected Smart Clients and ADO.NET Sync Services</a></li>
</ul>
<p>There&#8217;s also some more links under the <a href="http://udidahan.weblogs.us/first-time-here/#smart_client">Smart Client link</a> of my <a href="http://udidahan.weblogs.us/first-time-here/">&#8220;First time here?&#8221; page</a>.</p>
<p>Also, please join me in asking Microsoft for an update to these guides &#8211; comments below or your own blog posts would be great.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2008/06/09/prism-occasionally-connected/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WCF, Smart Clients, and Deadlocks</title>
		<link>http://www.udidahan.com/2008/04/11/wcf-smart-clients-and-deadlocks/</link>
		<comments>http://www.udidahan.com/2008/04/11/wcf-smart-clients-and-deadlocks/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 09:15:38 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Simplicity]]></category>
		<category><![CDATA[Smart Client]]></category>
		<category><![CDATA[Threading]]></category>
		<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/04/11/wcf-smart-clients-and-deadlocks/</guid>
		<description><![CDATA[There&#8217;s a new article up on MSDN describing how to write Smart Clients using WCF. The author is none other than WCF-Master Lowy and he goes over the multitude of ways you can deadlock yourself.
Here&#8217;s a taste:
UI Thread and Concurrency Management
Whenever you use hosting on the UI thread, deadlocks are possible. For example, the following [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a new article up on MSDN describing how to write Smart Clients using WCF. The author is none other than <a href="http://www.idesign.net/">WCF-Master Lowy</a> and he goes over the multitude of ways you can deadlock yourself.</p>
<p>Here&#8217;s a taste:</p>
<blockquote><h3>UI Thread and Concurrency Management</h3>
<p>Whenever you use hosting on the UI thread, deadlocks are possible. For example, the following setup is guaranteed to result with a deadlock: A Windows Forms application is hosting a service with <b>UseSynchronizationContext</b> set to <b>true</b>, and UI thread affinity is established. The Windows Forms application then calls the service over one of its endpoints. The call to the service blocks the UI thread, while WCF posts a message to the UI thread to invoke the service. That message is never processed, because of the blocking UI thread—hence, the deadlock.
<p>Another possible case for a deadlock occurs when a Windows Forms application is hosting a service with <b>UseSynchronizationContext</b> set to <b>true</b> and UI thread affinity is established. The service receives a call from a remote client. That call is marshaled to the UI thread and is eventually executed on that thread. If the service is allowed to call out to another service, that can result in a deadlock if the callout causality tries somehow to update the UI or call back to the service’s endpoint, because all of the service instances that are associated with any endpoint (regardless of the service-instancing mode) share the same UI thread.
<p>Similarly, you risk a deadlock if the service is configured for reentrancy and it calls back to its client. You risk a deadlock if the callback causality tries to update the UI or enter the service, because that reentrance must be marshaled to the blocked UI thread.</p>
</blockquote>
<p>Actually, I have difficulty believing that Juval would go so far as to suggest that even the forms should be services, but he does:<br />
<blockquote>
<h3>Form as a Service</h3>
<p>The main motivation for hosting a WCF service on the UI thread is if the service must update the UI or the form. The problem is always: How does the service reach out and obtain a reference to the form? While the techniques and ideas that appear thus far in the listings certainly work, <font color="#800000" size="4"><strong><em>it would be simpler yet if the form were the service</em></strong></font> and hosted itself. For this to work, the form (or any window) must be a singleton service. The reason is that singleton is the only instancing mode that enables you to provide WCF with a live instance to host. In addition, you would not want a per-call form that exists only during a client call (which is usually very brief), nor would you want a per-session form that only a single client can establish a session with and update.
<p>When a form is also a service, <font color="#800000" size="4"><strong><em>having that form as a singleton service is the best instancing mode all around</em></strong></font>.</p>
</blockquote>
<p>I think that this article serves as a great treatise leading to only one conclusion &#8211; you&#8217;d have to be crazy to try to do this without some higher level framework, preferably with a different low-level framework too <img src='http://www.udidahan.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  . Sucks Microsoft didn&#8217;t put one out &#8211; nor is there a pending beta, CTP, or even word about some project with a codename handling this. From what I know about <a href="http://www.codeplex.com/prism">Prism</a>, it doesn&#8217;t intend to handle this issue either.
<p>One thing that isn&#8217;t covered in the article is that if you do choose not to tie the client-side service to the UI thread, you open yourself up to race conditions. Reasons you&#8217;d want to handle messages on a different thread center around UI responsiveness. I&#8217;ve written about these things before:
<ul>
<li>
<h4><a href="http://udidahan.weblogs.us/2007/12/06/object-builder-the-place-to-fix-system-wide-threading-bugs/">Object Builder &#8211; the place to fix system-wide threading bugs</a></h4>
</li>
<li>
<h4><a href="http://udidahan.weblogs.us/2007/12/07/eureka-aop-is-the-final-piece-of-the-multi-threaded-smart-client-puzzle/">Eureka! AOP is the final piece of the multi-threaded smart client puzzle</a></h4>
</li>
<li>
<h4><a href="http://udidahan.weblogs.us/2007/12/26/what-makes-smart-clients-safe/">What Makes Smart Clients Safe?</a></h4>
</li>
</ul>
<p>The more I read things like this, the more I feel that I have to get going with my nServiceBus based solution. I&#8217;m fairly swamped as it is, so if anyone is interested in helping get this project off the ground, I&#8217;d be most grateful &#8211; as I think anyone else that had to build a smart client would. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2008/04/11/wcf-smart-clients-and-deadlocks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Differentiated UX &#8211; my a$$</title>
		<link>http://www.udidahan.com/2008/02/04/differentiated-ux-my-a/</link>
		<comments>http://www.udidahan.com/2008/02/04/differentiated-ux-my-a/#comments</comments>
		<pubDate>Mon, 04 Feb 2008 10:41:25 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[EDA]]></category>
		<category><![CDATA[Smart Client]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/04/differentiated-ux-my-a/</guid>
		<description><![CDATA[As if there wasn&#8217;t enough stuff for developers to deal with.
After the grand release of WPF, and the industry&#8217;s collective shrug and back to business, Microsoft stirs the pot again.
I&#8217;ve read Brian&#8217;s authoritative description, even done some of the examples he&#8217;s outlined, and let me tell you, tech won&#8217;t help.
Again.
I don&#8217;t know about differentiation, but [...]]]></description>
			<content:encoded><![CDATA[<p>As if there wasn&#8217;t enough stuff for developers to deal with.</p>
<p>After the grand release of WPF, and the industry&#8217;s collective shrug and back to business, Microsoft stirs the pot again.</p>
<p>I&#8217;ve read Brian&#8217;s authoritative <a href="http://briannoyes.net/2008/01/07/DifferentiatedUserExperienceUX.aspx">description</a>, even done some of the examples he&#8217;s outlined, and let me tell you, tech won&#8217;t help.</p>
<p>Again.</p>
<p>I don&#8217;t know about differentiation, but empowerment is important. Make the system work for the user. What an idea.</p>
<p>Let the user specify minimal inventory levels for products, and rules for replenishing. Give them a dashboard where they can see the status &#8211; what&#8217;s back ordered, orders expected to be authorized in the next relevant time interval, recent supplier timeliness, etc. If you&#8217;re thinking that this ties in to Event Driven Architecture, you&#8217;re right. Let the user subscribe to business events that interest them, pop up a messenger-like notification when they occur. Let the user click on the data in there, and have the rest of the UI synchronize around that. </p>
<p>Purchasing has struck a new deal with a supplier? Let me know. Click. Products they supply open in one view. Suppliers providing the same or similar products open in another. Contact info in another. Replenishment times in another.</p>
<p>Everything synchronized. Everything in real time. </p>
<p>Let them seamlessly work connected and disconnected.</p>
<p>You do that with regular boring winforms, and they&#8217;ll kiss the ground you walk on.</p>
<p>Differentiated user experience? Shrug.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2008/02/04/differentiated-ux-my-a/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What Makes Smart Clients Safe?</title>
		<link>http://www.udidahan.com/2007/12/26/what-makes-smart-clients-safe/</link>
		<comments>http://www.udidahan.com/2007/12/26/what-makes-smart-clients-safe/#comments</comments>
		<pubDate>Wed, 26 Dec 2007 07:42:13 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Smart Client]]></category>
		<category><![CDATA[Threading]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/12/26/what-makes-smart-clients-safe/</guid>
		<description><![CDATA[ After my recent post on using AOP for smart client development, my partner-in-crime, Arnon, suggested I explain a little bit more on the whole issue of multi-threading in the UI. This isn&#8217;t going to be another tired explanation of how you should only update controls on the main thread. This is going to be [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://udidahan.weblogs.us/wp-content/uploads/doctor-motion2.jpg"><img src="http://udidahan.weblogs.us/wp-content/uploads/doctor-motion2-thumb.jpg" style="border-width: 0px; margin: 0px 20px 20px" alt="doctor_motion2" align="right" border="0" height="244" width="150" /></a> After my <a href="http://udidahan.weblogs.us/2007/12/07/eureka-aop-is-the-final-piece-of-the-multi-threaded-smart-client-puzzle/">recent post</a> on using AOP for smart client development, my partner-in-crime, <a href="http://www.rgoarchitects.com/nblog/default.aspx">Arnon</a>, suggested I explain a little bit more on the whole issue of multi-threading in the UI. This isn&#8217;t going to be another tired explanation of how you should only update controls on the main thread. This is going to be a post on the challenges multi-threading brings and how to address them.</p>
<h3>Multiple Threads &#8211; Why?</h3>
<p>One of the properties of smart clients is that they should be able to work offline. Sometimes that means an explicit action of taking data and bringing it to the local machine so that the user can work on it, and other times it just has to do with the fact that wireless connectivity can be flaky. More interesting scenarios include the submission of batch jobs and receiving notification on when they complete. The bottom line is that the user should be able to continue doing their interactive work uninterrupted as all this is occurring.</p>
<p>While the user is disconnected, obviously the data they are working on is local &#8211; the client is not calling the server to perform the work on its behalf. However, in the flaky connectivity scenario, this happens all the time. In other words, the design should be the same for handling all scenarios. One thread for interacting with the user, and (at least) on other thread for handling the issues of connectivity. The one thing that is clear is that we are going to have data on the client with which the user interacts on one thread, and which the background thread will also be updating as notifications arrive from the server.</p>
<h3>Local Data and Multi-Threading &#8211; a Recipe for Disaster</h3>
<p>When multiple threads are working with the same data, unless some specific code is in that object to make it thread-safe, there&#8217;s a good chance that object will end up in an inconsistent state. This can be catastrophic if we&#8217;re talking about air traffic control systems, dispensing medication, factory floor automation, etc. The problem is that we can&#8217;t just lock down the entire system whenever something needs to be done. While in some cases I&#8217;ve seen projects make each object thread-safe, implementing some base class for handling locking, that doesn&#8217;t work between objects and results in deadlocks.</p>
<p>Just as an example of the multi-object problem, consider the doctor prescribing medication for a patient. Now, the data about a patient in a smart client is not all on the Patient Object &#8211; there are lists of connected test results, medication already being taken, which nurses and doctors have treated this patient so far, etc. As a test result gets pushed to the client from the server, a new doctor unfamiliar with the history of the patient orders the same test again. These two objects under Patient &#8211; TestRequest and TestResult are being acted upon by different threads. One of the goals of the system was to eliminate duplicate testing for patients &#8211; cited as costing the hospital chain millions of dollars a year. Good thing we addressed the cross-object multi-threaded locking thing properly <img src='http://www.udidahan.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h3>Always Switch from Background to Foreground?</h3>
<p>One solution I&#8217;ve seen used successfully is to always change threads from background to foreground whenever an update comes in from the server. This works when you don&#8217;t have many updates or the work performed on the client as a result of an update doesn&#8217;t take long. Always keep in mind, though, the flaky connectivity scenario. What tends to happen is that server notifications bunch up and then hit the client all together. When this occurs, clients developed this way are rendered unusable.</p>
<p>It would seem like this solution isn&#8217;t valid because of the above, but don&#8217;t dismiss it so quickly. This is an easy solution to implement that may address your specific environment and, as such, be cost effective. A large part of the work I&#8217;ve been doing is to make the more complex environments just as easy to develop as these simpler ones.</p>
<h3>Infrastructure-level, Safe, Multi-Object Locking</h3>
<p>Luckily for us developers, in the .net framework there is a class that handles this for us &#8211; well, 2 actually: <a href="http://msdn2.microsoft.com/en-us/library/system.contextboundobject(VS.90).aspx">ContextBoundObject</a> and <a href="http://msdn2.microsoft.com/en-us/library/system.runtime.remoting.contexts.synchronizationattribute.aspx">SynchronizationAttribute</a>. When using these two classes, we can create something known as a <a href="http://www.ddj.com/architect/184405771">Synchronization Domain</a> which acts as a global lock for all objects belonging to the synchronization domain. What this means is that if the user thread is trying to add a test request object while the background thread is already creating a test result object, the user thread will block automatically until the background thread completes its work.</p>
<p>There is only one teensy-weensy problem &#8211; ContextBoundObjects are really heavy-weight. The last thing you want is having millions of these running around in your client &#8211; you&#8217;ll end up with a multi-threading safe unusable UI. Also, the creation of an object inheriting from ContextBoundObject takes quite a bit longer than a plain-old.net object. In other words, technology by itself will not solve our problems &#8211; we need some patterns for the correct use of the technology so that we can maintain a reasonable level of performance while taking care of safety.</p>
<h3>MVC and Threading &#8211; Controllers</h3>
<p>Regardless of which flavour of MVC you prefer (I&#8217;m in the Supervising Controller camp for smart clients), the logic controlling what goes on in the client is found in the controllers. What this means is that actions from the user as well as background notifications will need to go through these controllers. It is important that these controllers be thread-safe since they are state-full &#8211; managing which windows are open, which step in a given process a user is currently doing, etc.</p>
<p>The characteristics of these controller objects which make them best suited to inherit from ContextBoundObject are that there are only a handful of these objects at any point in time and that they are created at startup &#8211; they&#8217;re singletons (in the &#8220;only-one-of-them&#8221; sense of the word).</p>
<p>The only special thing that controllers need to do in terms of threading is to dispatch calls to view objects on the foreground thread, even if the thread currently running is the background thread. For example, popping up a &#8220;toast&#8221; that a test result has arrived when a notification from the server comes in.</p>
<p>These elements &#8211; inheriting from ContextBoundObject, use of the SynchronizationAttribute, and thread-switching can be pulled up in to a BaseController class:</p>
<div style="overflow: scroll; width: 100%">
<style type="text/css">.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ }
.csharpcode pre { margin: 0em; }</p>
<p>.csharpcode .rem { color: #008000; }</p>
<p>.csharpcode .kwrd { color: #0000ff; }</p>
<p>.csharpcode .str { color: #006080; }</p>
<p>.csharpcode .op { color: #0000c0; }</p>
<p>.csharpcode .preproc { color: #cc6633; }</p>
<p>.csharpcode .asp { background-color: #ffff00; }</p>
<p>.csharpcode .html { color: #800000; }</p>
<p>.csharpcode .attr { color: #ff0000; }</p>
<p>.csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; }</p>
<p>.csharpcode .lnum { color: #606060; }</style>
<pre class="csharpcode"><span class="kwrd">using</span> System;
<span class="kwrd">using</span> System.ComponentModel;
<span class="kwrd">using</span> System.Runtime.Remoting.Contexts;

<span class="kwrd">namespace</span> ControllerFramework
{
    [Synchronization(SynchronizationAttribute.REQUIRED)]
    <span class="kwrd">public</span> <span class="kwrd">class</span> BaseController : ContextBoundObject
    {
        <span class="kwrd">protected</span> ISynchronizeInvoke invoker;
        <span class="kwrd">public</span> ISynchronizeInvoke Invoker
        {
            get { <span class="kwrd">return</span> invoker; }
            set { invoker = <span class="kwrd">value</span>; }
        }

        <span class="kwrd">protected</span> <span class="kwrd">void</span> MarshalToUiThread(Delegate toCall, <span class="kwrd">params</span> <span class="kwrd">object</span>[] parameters)
        {
            <span class="kwrd">if</span> (<span class="kwrd">this</span>.invoker == <span class="kwrd">null</span>)
                <span class="kwrd">return</span>;

            <span class="kwrd">if</span> (<span class="kwrd">this</span>.invoker.InvokeRequired)
                invoker.BeginInvoke(toCall, parameters);
            <span class="kwrd">else</span>
                toCall.DynamicInvoke(parameters);
        }
    }
}</pre>
</div>
<p>Well, I think that this is long enough for a single blog post. In the next instalment of this series I&#8217;ll be talking about how model objects and views fit into the multi-threaded smart client. After that, we&#8217;ll be seeing how service agents, messaging, and service contract design need to be done in this style. While all this blogging will be going on, I&#8217;ll be getting a software factory up that will tie all these patterns and frameworks together so that all developers will be able to write thread-safe, high-performance smart clients without needing a doctorate in computer science &#8211; not that I have one <img src='http://www.udidahan.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Questions? Comments? Thoughts?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/12/26/what-makes-smart-clients-safe/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Eureka! AOP is the final piece of the multi-threaded smart client puzzle</title>
		<link>http://www.udidahan.com/2007/12/07/eureka-aop-is-the-final-piece-of-the-multi-threaded-smart-client-puzzle/</link>
		<comments>http://www.udidahan.com/2007/12/07/eureka-aop-is-the-final-piece-of-the-multi-threaded-smart-client-puzzle/#comments</comments>
		<pubDate>Fri, 07 Dec 2007 23:01:50 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[AOP]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Dependency Injection]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Smart Client]]></category>
		<category><![CDATA[Threading]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/12/07/eureka-aop-is-the-final-piece-of-the-multi-threaded-smart-client-puzzle/</guid>
		<description><![CDATA[If you&#8217;ve read my recent post on the threading issues I&#8217;ve been dealing with in Smart Client Applications, then you&#8217;re probably beginning to get the picture that its fairly complex. To tell you the truth, it is. And up until this point I haven&#8217;t been able to find anything that&#8217;ll help &#8211; and that includes [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve read my recent post on the <a href="http://udidahan.weblogs.us/2007/12/06/object-builder-the-place-to-fix-system-wide-threading-bugs/">threading issues I&#8217;ve been dealing with in Smart Client Applications</a>, then you&#8217;re probably beginning to get the picture that its fairly complex. To tell you the truth, it is. And up until this point I haven&#8217;t been able to find anything that&#8217;ll help &#8211; and that includes the CAB/SCSF. But yesterday I had my epiphany. The answer was in AOP.</p>
<p>You see, the main problem that I hadn&#8217;t been able to solve was that in order for the code to be thread-safe, you had to make sure that no code in the views would/could change entity data. One solution is not to use data-binding, which sucks, but isn&#8217;t enough to be sure. Another solution is to have all supervising-controllers clone an entity before they give it to a view. Even if you could possibly code review every line of those classes, the new guy (or old guy who forgot) will, by accident, write one new line of code that could pass an entity to a view without cloning it first. That&#8217;s not a very sustainable solution.</p>
<p>This thing has been bothering me for a couple of months now and I hadn&#8217;t found a way around it. Until yesterday, like I said. I was talking to somebody about threading stuff, and somehow my unconscience lobbed me this thought about AOP. Now I&#8217;m not the sharpest pencil in the pack, but I know to listen when my unconscience &#8220;speaks&#8221;.</p>
<p>So I set about going over what I knew about AOP &#8211; interceptors, advisors, advice, introductions, etc, etc. And then it dawned on me. I could intercept all calls to any object that implemented IView, check the parameters of those calls, and if they implemented IEntity, to clone them before passing them through.</p>
<p>&lt;Homer-style WOOHOO /&gt;</p>
<p>The great thing is that developers don&#8217;t need to remember to clone entities &#8211; it happens automatically. The even greater thing is that this will lead developers to writing the correct kind of interaction between their views and supervising controllers.</p>
<p>Together with <a href="http://www.nServiceBus.com">nServiceBus</a>, this is going to make the extremely difficult problem of writing thread-safe smart clients possible. </p>
<p>I&#8217;ve never made use of AOP in a framework before so I&#8217;d like to get the broader community&#8217;s feedback on this before incorporating this in production. I&#8217;ve spoken with some serious AOP folks who have allayed most of my uncertainties, but I&#8217;d like to hear more. Anyway, here&#8217;s the <a href="http://udidahan.weblogs.us/wp-content/uploads/aoptest.zip">proof of concept</a> (that makes use of <a href="http://www.springframework.net">Spring</a>). </p>
<p>If this turns out to be a viable solution, I think we&#8217;ll have a solid environment for building a software factory on top of. That is something that I&#8217;m really excited about. In this multi-core future (present) that is upon us, multi-threading on the client is pretty much a necessity. We need a way to get things safe and stable by default without requiring a member of the CLR team to hold our hand.</p>
<p>Anybody who&#8217;s interested in helping, drop a comment below.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/12/07/eureka-aop-is-the-final-piece-of-the-multi-threaded-smart-client-puzzle/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Object Builder &#8211; the place to fix system-wide threading bugs</title>
		<link>http://www.udidahan.com/2007/12/06/object-builder-the-place-to-fix-system-wide-threading-bugs/</link>
		<comments>http://www.udidahan.com/2007/12/06/object-builder-the-place-to-fix-system-wide-threading-bugs/#comments</comments>
		<pubDate>Thu, 06 Dec 2007 10:38:59 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Scalability]]></category>
		<category><![CDATA[Smart Client]]></category>
		<category><![CDATA[Threading]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/12/06/object-builder-the-place-to-fix-system-wide-threading-bugs/</guid>
		<description><![CDATA[Last week I was at a client in their test lab and saw a strange bit of behavior. The system could be described as something like an air traffic control system, showing things moving around on a map. For just a second, a fraction of a second, one of the &#8220;planes&#8221; disappeared from the map [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I was at a client in their test lab and saw a strange bit of behavior. The system could be described as something like an air traffic control system, showing things moving around on a map. For just a second, a fraction of a second, one of the &#8220;planes&#8221; disappeared from the map and then reappeared again. </p>
<p>When I asked if anybody else saw it, one of the developers said, &#8220;Yeah, that happens sometimes &#8211; but it fixes itself right after that.&#8221;</p>
<p>&#8220;What if the user sends a command to the server making use of that location?&#8221;, the PM asked. &#8220;Could that cause them to collide?&#8221;</p>
<p>You could hear a pin drop.</p>
<p>After everyone got passed the preliminary shock, we got down to work. I asked if I could look at the logs, but after more than an hour, I found nothing. No reason to explain the strange behavior. I suggested doing some more instrumentation so that whenever a location changed on the client-side entities, we&#8217;d write that to the log.</p>
<p>After that, we ran the system again in the lab under the expected load (several hundred things moving every second, and the user doing the expected activity) and didn&#8217;t notice anything. An intern &#8220;volunteered&#8221; to keep working the system while the rest of us went to lunch. When we came back, he told us that everything seemed to be working OK.</p>
<p>These <a href="http://en.wikipedia.org/wiki/Heisenbug#Heisenbugs">Heisenbugs</a> are the things that keep me up at night. </p>
<p>&#8220;Watching the system changes its behavior&#8221;, one of the older devs nodded his head sagely.</p>
<p>Just as we were about to leave the lab another one of the developers gave a shout, &#8220;It did it again!&#8221;. We quickly stopped the system. Opened the (rather huge) log files and looked for the latest entries.</p>
<p>There it was.</p>
<p>A context switch between setting the latitude and longitude of an entity.</p>
<p>That should not have happened. Not that context switches don&#8217;t happen, but rather that it should have been impossible by design. We had made use of synchronization domains and the appropriate patterns so that two threads could never concurrently be working on the same instance of an entity. The synchronization features baked in to <a href="http://www.nServiceBus.com">nServiceBus</a> had taken care of everything up to that point.</p>
<p>Before getting into the threading solution, I want to address a specific alternate patch that was deployed in the meantime:</p>
<p>The solution for the long/lat problem was simple &#8211; just make Location a value object and use a single setter for it rather than one for Latitide and another for Longitude. We were still worried about other bits of data that were correllated in the domain &#8211; things that couldn&#8217;t be solved the same way. </p>
<p>After getting 3 grizzled C++ veterans in the room, we did a code walkthrough of the threading model of nServiceBus. We went through the nitty gritty details of synchronization domains, how the Bus object was outside of the domain, why that was important for user experience, how the message handlers couldn&#8217;t be ContextBoundObjects because of the performance impact of creating and destroying them at a high rate, why they couldn&#8217;t just be singletons, why they still had to run in the synchronization domain, so that the UI thread couldn&#8217;t work on the same (or related) objects at the same time, etc, etc.</p>
<p>And then it hit me.</p>
<p>The bus was communicated directly with the message handlers.</p>
<p>After the Object Builder created the message handler, the bus dispatched the message to the handler directly. And since the bus was outside the synchronization domain, then the thread calling into the handler wouldn&#8217;t have locked the domain, leaving the UI thread open to go in and touch those very same objects.</p>
<p>They say that really understanding the problem is 90% of the solution. I&#8217;m hoping to meet them some day, because they&#8217;re really smart.</p>
<p>All that we needed to do was have the Object Builder dispatch the message to the handler instead of the bus &#8211; since the builder was configured to be in the synchronization domain (on the client side). Something as simple as just adding the method:</p>
<div style="border-right: black 1px solid; padding-right: 1em; border-top: black 1px solid; padding-left: 1em; padding-bottom: 0em; overflow: auto; border-left: black 1px solid; padding-top: 0em; border-bottom: black 1px solid; font-family: courier; background-color: beige">
void BuildAndDispatch(Type typeToBuild, string methodName, params object[] methodArgs);
</div>
<p>So, instead of the bus using this code:</p>
<div style="border-right: black 1px solid; padding-right: 1em; border-top: black 1px solid; padding-left: 1em; padding-bottom: 0em; overflow: auto; border-left: black 1px solid; padding-top: 0em; border-bottom: black 1px solid; font-family: courier; background-color: beige">
object handler = this builder.Build(messageHandlerType);<br />
MethodInfo method = messageHandlerType.GetMethod(&#8221;Handle&#8221;);<br />
method.Invoke(handler, messageToBeDispatched);
</div>
<p>It would do:</p>
<div style="border-right: black 1px solid; padding-right: 1em; border-top: black 1px solid; padding-left: 1em; padding-bottom: 0em; overflow: auto; border-left: black 1px solid; padding-top: 0em; border-bottom: black 1px solid; font-family: courier; background-color: beige">
this.builder.BuildAndDispatch(messageHandlerType, &#8220;Handle&#8221;, messageToBeDispatched);
</div>
<p>[Just FYI, this is now up on the <a href="http://sourceforge.net/projects/nservicebus">sourceforge site</a>]</p>
<p>We redeployed the system to the lab, ran all the functional, stress, load, etc tests and everything appeared to be stable. The system has been under scrutiny for the past 4 days by batteries of testers instructed specifically to look for those strage kinds of behavior. Other developers are running scripts on the log files looking for other kinds of context switches that may have been missed by the testers. I am happy to report that they haven&#8217;t found anything.</p>
<p>Not that this means that the problem isn&#8217;t there. We really can&#8217;t be sure. However, the PM has decided that we are stable enough to go into pilot mode &#8211; deploying into production beside the current system; having users work on both systems at the same time. I&#8217;m optimistic.</p>
<p>I&#8217;m personally involved in two more production-projects that are making use of <a href="http://www.nServiceBus.com">nServiceBus</a> in similarly high-end situations and we&#8217;ve never had these threading problems &#8211; now two years running.</p>
<p>That was an interesting week.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/12/06/object-builder-the-place-to-fix-system-wide-threading-bugs/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>[Article] Occasionally Connected Systems Architecture: Concurrency</title>
		<link>http://www.udidahan.com/2007/10/16/article-occasionally-connected-systems-architecture-concurrency/</link>
		<comments>http://www.udidahan.com/2007/10/16/article-occasionally-connected-systems-architecture-concurrency/#comments</comments>
		<pubDate>Tue, 16 Oct 2007 23:17:52 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Smart Client]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/10/16/article-occasionally-connected-systems-architecture-concurrency/</guid>
		<description><![CDATA[My latest article has now been published on www.Developer.com:
Occasionally Connected Systems Architecture: Concurrency
When designing systems that support users who need to work offline, one of the challenges developers face is how to deal with concurrency problems when these users re-connect and synchronize their data with the server. Explore patterns for conflict identification and resolution in [...]]]></description>
			<content:encoded><![CDATA[<p>My latest article has now been published on <a href="http://www.developer.com">www.Developer.com</a>:</p>
<h3>Occasionally Connected Systems Architecture: Concurrency</h3>
<p>When designing systems that support users who need to work offline, one of the challenges developers face is how to deal with concurrency problems when these users re-connect and synchronize their data with the server. Explore patterns for conflict identification and resolution in the first of this series on Occasionally Connected Systems Architecture.</p>
<p><a href="http://www.developer.com/db/article.php/3705396">Continue reading</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/10/16/article-occasionally-connected-systems-architecture-concurrency/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Podcast] Thread-Safe Asynchronous Smart Clients</title>
		<link>http://www.udidahan.com/2007/10/12/podcast-thread-safe-asynchronous-smart-clients/</link>
		<comments>http://www.udidahan.com/2007/10/12/podcast-thread-safe-asynchronous-smart-clients/#comments</comments>
		<pubDate>Fri, 12 Oct 2007 07:08:09 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Ask Udi Podcast]]></category>
		<category><![CDATA[OO]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Smart Client]]></category>
		<category><![CDATA[Threading]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/10/12/podcast-thread-safe-asynchronous-smart-clients/</guid>
		<description><![CDATA[In this podcast we&#8217;ll look at various patterns involved in creating MVC-based Smart Clients which communicate using asynchronous messaging and how to avoid threading problems there. 
Neil asks:

Hi Udi,
We&#8217;re building a smart client application that uses WCF for full-duplex communications with our server. This is the asynchronous communication you talk about in your podcast. The [...]]]></description>
			<content:encoded><![CDATA[<p>In this podcast we&#8217;ll look at various patterns involved in creating MVC-based Smart Clients which communicate using asynchronous messaging and how to avoid threading problems there. </p>
<p>Neil asks:</p>
<blockquote><p>
Hi Udi,</p>
<p>We&#8217;re building a smart client application that uses WCF for full-duplex communications with our server. This is the asynchronous communication you talk about in your podcast. The smart-client is based on the MVC pattern, where model objects raise events when they&#8217;re changed so that the views can update themselves.</p>
<p>What&#8217;s started happening recently is that the smart-client has been freezing-up on us intermittently. We don&#8217;t know how to debug this and are wondering if its an architectural problem.</p>
<p>Any help you can give would be most appreciated.</p>
<p>Neil
</p></blockquote>
<p><b>Download</b></p>
<p><a href="http://www.ddj.com/architect/202401468">Download via the Dr. Dobb&#8217;s site</a></p>
<p>Or download directly <a href="http://www.dobbsprojects.com/media/newengine/dynamp.php/071011ud01.mp3?podcast=071011ud01.mp3">here</a></p>
<p><b>Additional References</b></p>
<ul>
<li>Blog post on <A href="http://udidahan.weblogs.us/2007/04/04/occasionally-connected-systems-architecture/">Occasionally Connected Systems Architecture</A></li>
<li>Blog post on <A href="http://udidahan.weblogs.us/2007/09/28/objectbuilder-synchronization-features-needed-for-pubsub-ing-smart-clients/">ObjectBuilder synchronization features needed for pub/sub-ing Smart Clients</A></li>
</ul>
<p><b>Want more?</b></p>
<p>Check out the <a href="/ask-udi/">&#8220;Ask Udi&#8221; archives</a>.</p>
<p><b>Got a question?</b></p>
<p><a href="mailto:podcast@UdiDahan.com">Send Udi your question to answer on the show.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/10/12/podcast-thread-safe-asynchronous-smart-clients/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
<enclosure url="http://www.dobbsprojects.com/media/newengine/dynamp.php/071011ud01.mp3?podcast=071011ud01.mp3" length="13030892" type="audio/mp3" />
		</item>
		<item>
		<title>ObjectBuilder synchronization features needed for pub/sub-ing Smart Clients</title>
		<link>http://www.udidahan.com/2007/09/28/objectbuilder-synchronization-features-needed-for-pubsub-ing-smart-clients/</link>
		<comments>http://www.udidahan.com/2007/09/28/objectbuilder-synchronization-features-needed-for-pubsub-ing-smart-clients/#comments</comments>
		<pubDate>Fri, 28 Sep 2007 21:36:58 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[Dependency Injection]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Pub/Sub]]></category>
		<category><![CDATA[Smart Client]]></category>
		<category><![CDATA[Threading]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/09/28/objectbuilder-synchronization-features-needed-for-pubsub-ing-smart-clients/</guid>
		<description><![CDATA[I&#8217;ve been getting some questions from the Dependency Injection folks out there as to why I have my own Object Builder wrapping the framework. There are two very good reasons why I do this:
The first is to insulate the framework and application code that I write from the choice of one dependency injection technology or [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been getting some questions from the Dependency Injection folks out there as to why I have my own Object Builder wrapping the framework. There are two very good reasons why I do this:</p>
<p>The first is to insulate the framework and application code that I write from the choice of one dependency injection technology or another. I want the ability to switch easily from one to the other &#8211; not so much that projects go back and forth. Updating those config files is definitely <i>not</i> easy. However, it allows me to have &#8220;portable&#8221; framework code that is applicable to all the projects I consult on, regardless of their choice of technology.</p>
<p>The second has to do with <a href="http://udidahan.weblogs.us/category/nservicebus/">NServiceBus</a> specifically. In order to make use of duplex communication on smart clients, you need a background thread. That thread will be updating the same (model) objects as the UI thread. That means we need synchronization. I prefer to use .NET&#8217;s built-in synchronization domains in order to solve this rather thorny problem.</p>
<p>The only thing is that message handlers need to be in the synchronization domain so that they can easily update those objects. However, the Bus object must not be in the synchronization domain so that if we&#8217;ve received a large update from the server, we won&#8217;t be locking out the UI thread from interacting with data on the client. </p>
<p>Since the bus makes use of a dependency injection framework to create message handlers, this was the best place to put the code which causes message handlers to run within the synchronization domain.</p>
<p>Be aware that in order to enjoy this feature, you need to split up those large server updates into multiple, logical objects (that implement IMessage), but you can still publish them all in one go using the method: </p>
<p>void Publish(params IMessage[] messages);</p>
<p>And, of course, you need to set the JoinSynchronizationDomain property of the Object Builder.</p>
<p>I&#8217;ll have a podcast coming out on this topic soon.</p>
<p>You can get the code here:</p>
<p><a href='http://udidahan.weblogs.us/wp-content/uploads/objectbuilder.zip' title='Object Builder.zip'>Object Builder.zip</a></p>
<p>But you&#8217;ll have to get the Spring Framework code from the <a href="http://springframework.net/">official site</a>. Make sure you download <a href="http://sourceforge.net/project/showfiles.php?group_id=106751">RC 1.1</a>. Then, take the binaries and copy them to the &#8220;BIN&#8221; folder of the Object Builder solution. If you&#8217;re looking to save on some &#8220;weight&#8221;, you only need &#8220;Spring.Core.dll&#8221;, &#8220;Common.Logging.dll&#8221; and &#8220;antlr.runtime.dll&#8221; for the solution to compile. You will need one of the logging implementations DLLs to get anything written to a log, obviously.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/09/28/objectbuilder-synchronization-features-needed-for-pubsub-ing-smart-clients/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>[Podcast] Passing Data Between Layers in SOA Model/Smart Client Application</title>
		<link>http://www.udidahan.com/2007/07/12/podcast-passing-data-between-layers-in-soa-modelsmart-client-application/</link>
		<comments>http://www.udidahan.com/2007/07/12/podcast-passing-data-between-layers-in-soa-modelsmart-client-application/#comments</comments>
		<pubDate>Thu, 12 Jul 2007 22:37:18 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Ask Udi Podcast]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Smart Client]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/07/12/podcast-passing-data-between-layers-in-soa-modelsmart-client-application/</guid>
		<description><![CDATA[This week we discuss the different options that are available for passing data between a client and a service, as well as common pitfalls around trying to use the same objects for both presentation to the user and persistence to the database.
Download via the Dr. Dobb&#8217;s site.
Or download directly here.
And here&#8217;s the question that gets [...]]]></description>
			<content:encoded><![CDATA[<p>This week we discuss the different options that are available for passing data between a client and a service, as well as common pitfalls around trying to use the same objects for both presentation to the user and persistence to the database.</p>
<p><a href="http://ddj.com/dept/webservices/201001098">Download via the Dr. Dobb&#8217;s site.</a></p>
<p>Or download directly <a href="http://www.dobbsprojects.com/media/newengine/dynamp.php/070712ud01.mp3?podcast=070712ud01.mp3">here</a>.</p>
<p>And here&#8217;s the question that gets us started:</p>
<blockquote><p>
Hello there, </p>
<p>We are developing an application in .NET Smart Client application which connects to a WCF service and then to the data access layer.  The issue we have here is on the type of data which can be passed between the client side and web service. </p>
<p>1. Can it be a dataset (No!), custom entity or XML or anything else ? </p>
<p>     Which is the best one ?</p>
<p>2. Ofcourse , a dataset can&#8217;t be used coz it can&#8217;t be used in non-.NET environment?</p>
<p>3. If we go for custom-entity or XML how do we ensure the changes happen to the data during client-side actions ? For example, binding the XML or custom entity to a data grid can be done.  But if user makes any changes to the same,  how do we identify ?</p>
<p>4. If we use custom entities / XM L, the same can not be passed to the Data Access Application Block which invokes the data objects.</p>
<p>Note : All the above are based on assumption without using a translator in between any of the layers.</p>
<p>Please provide a better solution if you have come across any.
</p></blockquote>
<p><u>Additional References:</u></p>
<ul>
<li><a href="http://udidahan.weblogs.us/2007/03/28/podcast-datasets-web-services/">Podcast on using DataSets with Web Services</li>
<li><a href="http://udidahan.weblogs.us/2007/03/30/entity-framework-disconnected-problems-solutions/">Blog post on tracking changes to objects on the client side</a></li>
<li><a href="/ask-udi/">Looking for more of the &#8220;Ask Udi&#8221; podcast?</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/07/12/podcast-passing-data-between-layers-in-soa-modelsmart-client-application/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
<enclosure url="http://www.dobbsprojects.com/media/newengine/dynamp.php/070712ud01.mp3?podcast=070712ud01.mp3" length="15111103" type="audio/mp3" />
		</item>
		<item>
		<title>CAB and Acropolis of little help for SOA interactions</title>
		<link>http://www.udidahan.com/2007/06/27/cab-and-acropolis-of-little-help-for-soa-interactions/</link>
		<comments>http://www.udidahan.com/2007/06/27/cab-and-acropolis-of-little-help-for-soa-interactions/#comments</comments>
		<pubDate>Wed, 27 Jun 2007 20:57:04 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Smart Client]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/06/27/cab-and-acropolis-of-little-help-for-soa-interactions/</guid>
		<description><![CDATA[After reading Nick Malik&#8217;s recent post  describing what he likes about Acropolis I was reminded of a conversation I had with the guys behind the CAB. Nick writes:

What I find promising: an Acropolis part can essentially consume a SOA service, allowing the composition of process and activity services to be as simple as snapping [...]]]></description>
			<content:encoded><![CDATA[<p>After reading Nick Malik&#8217;s recent post <a href="http://blogs.msdn.com/nickmalik/archive/2007/06/26/what-i-like-about-acropolis.aspx"> describing what he likes about Acropolis</a> I was reminded of a conversation I had with the guys behind the CAB. Nick writes:</p>
<blockquote><p>
What I find promising: an Acropolis part can essentially consume a SOA service, allowing the composition of process and activity services to be as simple as snapping parts onto a surface.
</p></blockquote>
<p>Since services which conform to SOA principles will expose duplex/asynchronous APIs, this will almost necessarily make the client-side interaction multi-threaded. I do, and have done quite a lot of work on multi-threaded, thread-safe, smart clients. They&#8217;re hard. Here&#8217;s a post <a href="http://bits-in-motion.blogspot.com/2007/06/threading-in-uis.html">describing how hard</a>. There are other solutions as well, but very little of it has to do with technology. </p>
<p>Since both the CAB and Acropolis do very little in handling, or even describing in their docs these multi-threading issues, I don&#8217;t think that they&#8217;re going to make it simple or easy to work with SOA-style services. This is not to say they don&#8217;t provide any value. On the contrary, I think that they bring the mainstream many steps forward. However, there is still a long way to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/06/27/cab-and-acropolis-of-little-help-for-soa-interactions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why AsynchronousCommunication is in its own project</title>
		<link>http://www.udidahan.com/2007/06/14/why-asynchronouscommunication-is-in-its-own-project/</link>
		<comments>http://www.udidahan.com/2007/06/14/why-asynchronouscommunication-is-in-its-own-project/#comments</comments>
		<pubDate>Thu, 14 Jun 2007 19:46:47 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[ESB]]></category>
		<category><![CDATA[Pub/Sub]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Simplicity]]></category>
		<category><![CDATA[Smart Client]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/06/14/why-asynchronouscommunication-is-in-its-own-project/</guid>
		<description><![CDATA[I&#8217;ve gotten a couple of questions on my MSMQ implementation of an ESB as to why I chose to take the definition of the CompletionCallback and put it in its own project, rather than just putting it together with the IBus interface.
The answer to this is that this callback is designed for Controller classes in [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve gotten a couple of questions on my <a href="http://udidahan.weblogs.us/2007/04/22/basic-messaging-infrastructure/">MSMQ implementation of an ESB</a> as to why I chose to take the definition of the CompletionCallback and put it in its own project, rather than just putting it together with the IBus interface.</p>
<p>The answer to this is that this callback is designed for Controller classes in <a href="http://udidahan.weblogs.us/smart-client/">Smart Clients</a>, at least when employing an MVC style. You see, as the Controller class is the one who decided to initiate the action on the remote service by calling into a Service Agent class, it will also contain the logic for what to do when a result arrives. Therefore, it needs to pass a callback to the Service Agent class, possibly also passing in some other state (for instance, a reference to the form for which it is making this call, if there can be multiple instances of the same type of form open).</p>
<p>The only dependency the Controller class has is on the fact that there is asynchronous communication happening &#8211; made clear by the tiny assembly containing only the callback definition. The Controller does not need to know anything about ESBs and such, and thus does not need a reference to the IBus interface project.</p>
<p>As always, when working asynchronously you need to be aware that these callbacks will be coming in on a thread other than the UI thread. This means that if your Controller class has any state (ie. member variables), you need to protect that.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/06/14/why-asynchronouscommunication-is-in-its-own-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generic Validation</title>
		<link>http://www.udidahan.com/2007/04/30/generic-validation/</link>
		<comments>http://www.udidahan.com/2007/04/30/generic-validation/#comments</comments>
		<pubDate>Mon, 30 Apr 2007 21:54:26 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[Dependency Injection]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[OO]]></category>
		<category><![CDATA[Simplicity]]></category>
		<category><![CDATA[Smart Client]]></category>
		<category><![CDATA[Validation]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/04/30/generic-validation/</guid>
		<description><![CDATA[Ayende brought up the topic of Input &#038; Business Rule Validation and I wanted to post how I solve this issue.
On kind of input validation is something you do as close to the user as possible for performance reasons. This includes all sorts of smart stuff you can do with JavaScript in Web scenarios. When [...]]]></description>
			<content:encoded><![CDATA[<p>Ayende brought up the topic of <a href="http://ayende.com/Blog/archive/2007/04/02/Input-Validation-vs.Business-Rules-Validation.aspx">Input &#038; Business Rule Validation</a> and I wanted to post how I solve this issue.</p>
<p>On kind of input validation is something you do as close to the user as possible for performance reasons. This includes all sorts of smart stuff you can do with JavaScript in Web scenarios. When in a <a href="http://udidahan.weblogs.us/category/smart-client/">Smart Client</a> environment, you usually have greater capabilities.</p>
<p>When I look at the issue of validation, I see that it centers around the entity. Sometimes, it is also affected by other things, like what process are we in (as described in the comments on Ayende&#8217;s post).</p>
<p>So, we can model the thing that validates an entity with an interface, say, IValidator&lt;T&gt; where T : IEntity. This interface will have one main method: bool IsValid(T entity); and one main property: string ErrorDescription { get; }</p>
<p>What this allows us to do is to separate out different validation concerns into different classes, yet have all of them implement the same interface.</p>
<p>The next thing we&#8217;ll need is to be able to get an instance for each of the classes that is a validator for a specific kind of entity. For instance, when the NewCustomerView raises an event proclaiming that it has a Customer object ready to be saved, the Controller will want to find all classes that implement IValidator&lt;Customer&gt; so that it can run all the validation rules.</p>
<p>Luckily, the <a href="http://udidahan.weblogs.us/2007/04/09/advanced-object-creation-with-dependency-injection/">generics patch</a> I put out for the <a href="http://www.springframework.net">Spring.Net Framework</a> allows us to do this in one simple line of code:</p>
<pre>
IList&lt;IValidator&lt;Customer&gt;&gt; validators = spring.GetObjectsOfType(typeof(IValidator&lt;Customer&gt;));
</pre>
<p>and quite simply perform the validation as follows:</p>
<pre>
foreach(IValidator&lt;Customer&gt; v in validators)
&nbsp;&nbsp;if (!v.IsValid(myCustomer))
&nbsp;&nbsp;&nbsp;&nbsp;// notify user with v.ErrorDescription, write to log, whatever
</pre>
<p>Now, when using this in Smart Client scenarios, you will often have views that allow the user to enter in a single entity which you will then want to validate. If you have those views implement a generic interface like: IEntityView&lt;T&gt; where T : IEntity, then you could have a single base class implement a &#8220;Validate&#8221; method, which would perform the work above generically like so:</p>
<pre>
foreach(IValidator&lt;T&gt; v in spring.GetObjectsOfType(typeof(IValidator&lt;T&gt;)))
&nbsp;&nbsp;if (!v.IsValid(this.Entity))
&nbsp;&nbsp;&nbsp;&nbsp;// notify user with v.ErrorDescription
</pre>
<p>and just have your specific view call that method on the button click.</p>
<p>This enables all entity views to activate all the relevant custom validation logic without being tied to it. It also enables you to extend your system by adding new classes implementing the IValidator&lt;T&gt; interface, and have them automatically run without even changing a config file. How&#8217;s that for loose coupling?</p>
<p>Finally, on the issue of tying validation rules to specific processes, this can be done by extending the interface to: IValidator&lt;T, P&gt; where T : IEntity, P : IProcess; You then model each process with a marker interface. You then have your specific validation classes implement the above generic interface for each specific process interface. For instance, say we have a validation rule that needs to run for processes P1 (marked by IP1), and P2 (marked by IP2), but not P3 (marked by IP3), which validates entities of type E. This would be done by defining the class like so:</p>
<pre>
public class MyValidator : IValidator&lt;E, IP1&gt;, IValidator&lt;E, IP2&gt; {}
</pre>
<p>and the Controller class that would request validators for process 2 would just call:</p>
<pre>
spring.GetObjectsOfType(typeof(IValidator&lt;T, IP2&gt;));
</pre>
<p>That&#8217;s it. The basic principles are simple, but, as you can see, can create very powerful structures. I&#8217;ve got to say that this exemplifies one of the reasons why I love generics so much. When used with <a href="http://udidahan.weblogs.us/category/dependency-injection/">Dependency Injection</a>, and/or Delegates, and/or Anonymous Methods, you get such a power of expression just by defining an interface. This is one of things that make coding fun for me. Or maybe I&#8217;m just wierd that way <img src='http://www.udidahan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/04/30/generic-validation/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Object/Relational Mapping and Scalability</title>
		<link>http://www.udidahan.com/2007/04/21/objectrelational-mapping-and-scalability/</link>
		<comments>http://www.udidahan.com/2007/04/21/objectrelational-mapping-and-scalability/#comments</comments>
		<pubDate>Sat, 21 Apr 2007 14:19:56 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Caching]]></category>
		<category><![CDATA[DDD]]></category>
		<category><![CDATA[Data Access]]></category>
		<category><![CDATA[NHibernate]]></category>
		<category><![CDATA[Scalability]]></category>
		<category><![CDATA[Smart Client]]></category>
		<category><![CDATA[Usability]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/04/21/objectrelational-mapping-and-scalability/</guid>
		<description><![CDATA[&#8220;How come there is no talk about scaling these ORMs?&#8221;.
The answer is simple.
You don&#8217;t have to.
Or, if you think you do, you&#8217;re probably using them wrong.
An O/R mapper should NOT live in its own tier.
Object/Relational Mappers never stand alone. They are used to provide persistence for something else &#8211; either for the Domain Model Pattern [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://codeliability.blogspot.com/2007/04/orm-and-when-query-plans-go-bad.html">&ldquo;How come there is no talk about scaling these ORMs?&rdquo;</a>.</p>
<p>The answer is simple.</p>
<p>You don&rsquo;t have to.</p>
<p>Or, if you think you do, you&rsquo;re probably using them wrong.</p>
<p>An O/R mapper should NOT live in its own <a href="http://udidahan.weblogs.us/2007/03/24/fear-those-tiers-iasa/">tier</a>.</p>
<p><a href="http://udidahan.weblogs.us/category/nhibernate/">Object/Relational Mappers</a> never stand alone. They are used to provide persistence for something else &ndash; either for the <a href="http://udidahan.weblogs.us/2007/04/21/domain-model-pattern/">Domain Model Pattern</a> or for the Active Record pattern.</p>
<p>In terms of <a href="http://udidahan.weblogs.us/category/scalability/">scalability</a>, again these patterns usually don&rsquo;t stand by themselves, but rather are hosted by something else. When used on the client side, say in a <a href="http://udidahan.weblogs.us/category/smart-client/">smart client</a> application, then scalability isn&rsquo;t often considered. There are some kinds of smart clients where hitting the database on most <a href="http://udidahan.weblogs.us/category/usability/">user interactions</a> will bring the system to its knees, but that&rsquo;s again an issue of database scalability. The common solution is some kind of client-side <a href="http://udidahan.weblogs.us/category/caching/">caching</a>.</p>
<p>Anyway, the two main parameters you need to look at for your common and high-load scenarios when using an O/R mapper are these:</p>
<ul>
<li>How many times do you hit the DB per business action.</li>
<li>How many objects/records/rows/columns do you bring into memory per business action.</li>
</ul>
<p>You should be looking at appropriate uses of <a href="http://udidahan.weblogs.us/2007/04/15/lazy-loading-and-how-messaging-fixes-everything-again/">Lazy Loading</a> for both of them.</p>
<p>Finally, keep in mind that O/R mappers are only part of your solution. Measure and optimize wisely.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/04/21/objectrelational-mapping-and-scalability/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Podcast] Occasionally Connected Smart Clients and ADO.NET Sync Services</title>
		<link>http://www.udidahan.com/2007/04/17/podcast-occasionally-connected-smart-clients-and-adonet-sync-services/</link>
		<comments>http://www.udidahan.com/2007/04/17/podcast-occasionally-connected-smart-clients-and-adonet-sync-services/#comments</comments>
		<pubDate>Tue, 17 Apr 2007 21:12:15 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[ADO.NET]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Ask Udi Podcast]]></category>
		<category><![CDATA[DataSets]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Smart Client]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/04/17/podcast-occasionally-connected-smart-clients-and-adonet-sync-services/</guid>
		<description><![CDATA[This week&#8217;s question comes from Oran who asks:

Hi Udi, 
I&#8217;m enjoying the recent discussion on Entity Framework, disconnected clients, Unit of Work, and messaging.  A few weeks ago I wrote a note to self to &#8220;Ask Udi&#8221; about the new ADO.NET Sync Services coming out of Microsoft, and this seems to be the perfect [...]]]></description>
			<content:encoded><![CDATA[<p>This week&#8217;s question comes from Oran who asks:</p>
<blockquote><p>
Hi Udi, </p>
<p>I&#8217;m enjoying the recent discussion on <a href="http://udidahan.weblogs.us/2007/03/30/entity-framework-disconnected-problems-solutions/">Entity Framework</a>, <a href="http://udidahan.weblogs.us/2007/04/04/occasionally-connected-systems-architecture/">disconnected clients</a>, Unit of Work, and <a href="http://udidahan.weblogs.us/2007/03/31/tasks-messages-transactions-%e2%80%93-the-holy-trinity/">messaging</a>.  A few weeks ago I wrote a note to self to <a href="/ask-udi">&#8220;Ask Udi&#8221;</a> about the new ADO.NET Sync Services coming out of Microsoft, and this seems to be the perfect timing.  </p>
<p>It really seems that Sync Services is meant to address the disconnected problem raised by Andres, but it appears to be primarily targeted at enabling <a href="http://udidahan.weblogs.us/category/datasets/">DataSet</a>-centric, grid-oriented UIs, not task-oriented UIs.  They are spinning Sync Services as being an <a href="http://udidahan.weblogs.us/category/soa/">&#8220;SOA&#8221;</a> way of doing data synchronization because &#8220;it uses <a href="http://udidahan.weblogs.us/category/wcf/">WCF</a>&#8221; and &#8221; supports n-tier&#8221;.  But under the hood it&#8217;s all about DataSet-style deltas.  See Steve Lasker&#8217;s <a href="http://blogs.msdn.com/stevelasker/archive/2007/03/18/QAforOCS_2D00_SyncServicesForAdoNet.aspx">first Q&#038;A for the SOA spin</a>, and the rest of his blog for more info.</p>
<p>I&#8217;m curious what your thoughts are on the subject.  Do you see Sync Services as a valid service-oriented solution for occasionally-connected clients, or is it just another attempt by the ADO.NET team to keep us all hooked on DataSet-driven development?</p>
<p>Oran
</p></blockquote>
<p>Get it via the Dr. Dobb&#8217;s site <a href="http://ddj.com/dept/webservices/199100027">here</a>.</p>
<p>Or download directly <a href="http://www.dobbsprojects.com/media/newengine/dynamp.php/070416ud01.mp3?podcast=070416ud01.mp3">here</a>.</p>
<p><u>Additional References</u></p>
<ul>
<li><a href="http://udidahan.weblogs.us/2007/04/04/occasionally-connected-systems-architecture/">Occasionally Connected Systems Architecture</a></li>
<li><a href="http://udidahan.weblogs.us/2007/03/30/entity-framework-disconnected-problems-solutions/">Entity Framework: Disconnected Problems &#038; Solutions</a></li>
<li><a href="http://udidahan.weblogs.us/2007/03/31/tasks-messages-transactions-%e2%80%93-the-holy-trinity/">Tasks, Messages, &#038; Transactions&#8211;the holy trinity</a></li>
</ul>
<p>Want more? Go to the <a href="/ask-udi">&#8220;Ask Udi&#8221; archives</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/04/17/podcast-occasionally-connected-smart-clients-and-adonet-sync-services/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
<enclosure url="http://www.dobbsprojects.com/media/newengine/dynamp.php/070416ud01.mp3?podcast=070416ud01.mp3" length="14630866" type="audio/mp3" />
		</item>
		<item>
		<title>Occasionally Connected Systems Architecture</title>
		<link>http://www.udidahan.com/2007/04/04/occasionally-connected-systems-architecture/</link>
		<comments>http://www.udidahan.com/2007/04/04/occasionally-connected-systems-architecture/#comments</comments>
		<pubDate>Wed, 04 Apr 2007 23:58:21 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Smart Client]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/04/04/occasionally-connected-systems-architecture/</guid>
		<description><![CDATA[Many systems don&#8217;t operate in environments where &#8220;client&#8221; machines have uninterrupted connectivity with &#8220;server&#8221; machines. This has already been stated more generally in the &#8220;8 Fallacies of Distributed Computing&#8221; &#8211; the network is not reliable. Let&#8217;s take a look at some patterns that alleviate many of the burdens of handling these difficult scenarios. We&#8217;ll be [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><span lang="EN-US" style="mso-ansi-language: EN-US"><font face="Calibri" size="3">Many systems don&rsquo;t operate in environments where &ldquo;client&rdquo; machines have uninterrupted connectivity with &ldquo;server&rdquo; machines. This has already been stated more generally in the &ldquo;</font><a href="http://en.wikipedia.org/wiki/Fallacies_of_Distributed_Computing"><font face="Calibri" size="3">8 Fallacies of Distributed Computing</font></a><font face="Calibri" size="3">&rdquo; &ndash; the network is not reliable. Let&rsquo;s take a look at some patterns that alleviate many of the burdens of handling these difficult scenarios. We&rsquo;ll be going through these patterns broken down primarily by the list that Roger Jennings published about </font><a href="http://oakleafblog.blogspot.com/2007/03/operation-and-entity-framework.html"><font face="Calibri" size="3">some of the architectural characteristics</font></a><font face="Calibri" size="3"> of Occasionally Connected Systems (OCS). I&rsquo;ll be addressing the points Frans raised in his </font><a href="http://weblogs.asp.net/fbouma/archive/2007/04/03/why-change-tracking-has-to-be-part-of-an-entity-object.aspx"><font face="Calibri" size="3">in-depth analysis of Entity Change Tracking</font></a><font size="3"><font face="Calibri"> in a separate post. <o:p></o:p></font></font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><span lang="EN-US" style="mso-ansi-language: EN-US"><font face="Calibri" size="5">The lowly GUID</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><span lang="EN-US" style="mso-ansi-language: EN-US"><font size="3"><font face="Calibri">One of the simpler patterns that, when viable, keeps basic things simple is that of Client-side Identifier Generation -<span style="mso-spacerun: yes">&nbsp; </span>if client-side code is capable of creating entities and giving them an identifier which will not be changed at the time those entities are persisted. The simplest implementation of this pattern is to use a Globally Unique Identifier (GUID) to identify entities in the systems. By having client-side code creating objects whose identities will be correct even before saving them, we are saved the chore of refreshing all the objects the client created when it eventually gets connected to the server again and can save those objects.<o:p></o:p></font></font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><span lang="EN-US" style="mso-ansi-language: EN-US"><font size="3"><font face="Calibri">One requirement that Roger mentions moves the architecture more towards an &ldquo;N-Tier&rdquo; style and further from the classic &ldquo;Client-Server&rdquo; style:<o:p></o:p></font></font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><em><span lang="EN-US" style="mso-ansi-language: EN-US"><font size="3"><font face="Calibri">&ldquo;Locally cached lookup (catalog or historical) data, which can be very large and thus must merge changes rather than require full-table refreshes&rdquo;<o:p></o:p></font></font></span></em></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><span lang="EN-US" style="mso-ansi-language: EN-US"><font face="Calibri" size="5">Messaging &#038; Pub/Sub</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><span lang="EN-US" style="mso-ansi-language: EN-US"><font face="Calibri" size="3">By employing the publish/subscribe pattern between clients and an application server, as well as </font><a href="http://www.enterpriseintegrationpatterns.com/DurableSubscription.html"><font face="Calibri" size="3">durable subscriptions</font></a><font face="Calibri" size="3"> when clients get connected they get pushed only the updates since the last time they were connected. This pattern improves scalability in that it prevents the scenario of many client connecting and performing costly queries against the database at the same time. Another difference between this (messaging-based) pattern and the more common database-level synchronization is that it maintains the discrete units-of-work (</font><a href="http://www.martinfowler.com/eaaCatalog/unitOfWork.html"><font face="Calibri" size="3">pattern</font></a><font size="3"><font face="Calibri">) that were performed. While this isn&rsquo;t very important for updates being pushed from the server to the client, it is absolutely critical for changes the client wants to send the server. These are the relevant architectural characteristics:<o:p></o:p></font></font></span></p>
<p class="MsoListParagraphCxSpFirst" style="MARGIN: 0cm 0cm 0pt 36pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1"><span lang="EN-US" style="FONT-FAMILY: Symbol; mso-ansi-language: EN-US; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; mso-bidi-font-style: italic"><span style="mso-list: Ignore"><font size="3">&middot;</font><span style="FONT: 7pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span dir="ltr"></span><em><span lang="EN-US" style="mso-ansi-language: EN-US"><font face="Calibri"><font size="3">&ldquo;Automatic or semi-automatic push of cached data to the server (two-tier) or data service (n-tier) when connected to the network&rdquo;<o:p></o:p></font></font></span></em></p>
<p class="MsoListParagraphCxSpMiddle" style="MARGIN: 0cm 0cm 0pt 36pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1"><span lang="EN-US" style="FONT-FAMILY: Symbol; mso-ansi-language: EN-US; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; mso-bidi-font-style: italic"><span style="mso-list: Ignore"><font size="3">&middot;</font><span style="FONT: 7pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span dir="ltr"></span><em><span lang="EN-US" style="mso-ansi-language: EN-US"><font face="Calibri"><font size="3">&ldquo;A process to enable the client to resolve data update and deletion concurrency conflicts; alternatively, to notify the client of the action taken by a business rule&rdquo;<o:p></o:p></font></font></span></em></p>
<p class="MsoListParagraphCxSpLast" style="MARGIN: 0cm 0cm 10pt 36pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1"><span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; mso-bidi-font-style: italic"><span style="mso-list: Ignore"><font size="3">&middot;</font><span style="FONT: 7pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span dir="ltr"></span><em><font size="3"><font face="Calibri"><span lang="EN-US" style="mso-ansi-language: EN-US">&ldquo;A process to enable the client to resolve insert and other conflicts with multiple rows of child tables, such as order or medication line items&rdquo;</span><o:p></o:p></font></font></em></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><span lang="EN-US" style="mso-ansi-language: EN-US"><font face="Calibri" size="5">Be neither overly optimistic nor overly pessimistic</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><font face="Calibri" size="3">One of the greatest challenges of the business logic in these systems is the handling of concurrency conflicts &ndash; multiple users changing the same set of data independent of each other and now trying to &ldquo;upload&rdquo; those changes to the server. This is handled on the server-side by the techniques I detailed in &ldquo;</font><a href="http://udidahan.weblogs.us/2007/01/22/realistic-concurrency/"><font face="Calibri" size="3">Realistic Concurrency</font></a><font face="Calibri" size="3">&rdquo;, but it is critical to have the client pass the Units-of-Work it performed to the server for that to work. By modelling these units-of-work as messages that the client sends to the server, buffering them when there&rsquo;s no connectivity, we are able to employ these Connected-Systems patterns as well.</font></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><span lang="EN-US" style="mso-ansi-language: EN-US"><font face="Calibri" size="5">Caching</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><font face="Calibri" size="3">Another interesting question is how the data is cached on the client. Before we get into the solutions, I think that we need to divide this question into two parts. Given a connected system, what is the best way to structure data on the client side; and does the fact that the client is occasionally connected change anything? Ayende </font><a href="http://www.ayende.com/Blog/archive/2007/03/23/The-Fallacy-of-Shared-Entity-Model.aspx"><font face="Calibri" size="3">suggest separate data structures for the client and server</font></a><font face="Calibri" size="3">. I strongly agree &ndash; regardless of connectivity. I suppose that this is one of the reasons that I don&rsquo;t particularly like using datasets on the client &ndash; it is so strongly tied to persistence concerns that don&rsquo;t worry me on the client.</font></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><span lang="EN-US" style="mso-ansi-language: EN-US"><font face="Calibri" size="5">A different model for the client</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><font face="Calibri" size="3">As for the second question &ndash; does connectivity change the client-side model? I have found that it does, but that it&rsquo;s much more an issue of the kind of work that can be performed disconnected. If we choose to employ asynchronous messaging, we may need to handle cases where, due to message-design considerations, the client can get published child objects before parents. It is fairly straight-forward to handle this by simply storing both the parent ID and a reference to the parent object in child objects. In order to keep this data correct, it wise to update objects only by calling business-level methods on them rather then calling multiple setter-methods one after another.</font></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><font face="Calibri" size="3">One other issue is where these objects are stored on the client-side. In connected scenarios, this issue doesn&rsquo;t exist until caching is involved. What I often use is a derivative of the </font><a href="http://patternshare.org/default.aspx/Home.MF.Repository?diff=y"><font face="Calibri" size="3">Repository pattern</font></a><font face="Calibri" size="3">. This repository enables searching for objects on the client-side, persists itself to some durable storage (like the file system) when the client application is shut down, and loads those objects from the storage on startup.</font></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><span lang="EN-US" style="mso-ansi-language: EN-US"><font face="Calibri" size="5">Wrapping up</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><font face="Calibri" size="3">While this isn&rsquo;t an exhaustive treatment of all issues related to Occasionally Connected Systems Architecture, I hope that it serves as a good baseline for discussing techniques and technologies.</font></p>
<hr size="1" />
<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><span lang="EN-US" style="mso-ansi-language: EN-US"><font face="Calibri" size="5">Related content</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><font face="Calibri" size="3"><a href="http://www.udidahan.com/2007/04/17/podcast-occasionally-connected-smart-clients-and-adonet-sync-services/">Podcast on Occasionally Connected Smart Clients</a><br/><a href="http://www.udidahan.com/2007/07/12/podcast-passing-data-between-layers-in-soa-modelsmart-client-application/">Podcast on passing data between layers in occasionally connected systems</a><br/></font></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/04/04/occasionally-connected-systems-architecture/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>From Disconnected Scenarios to SOA</title>
		<link>http://www.udidahan.com/2007/04/01/from-disconnected-scenarios-to-soa/</link>
		<comments>http://www.udidahan.com/2007/04/01/from-disconnected-scenarios-to-soa/#comments</comments>
		<pubDate>Sun, 01 Apr 2007 20:58:50 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[SOA]]></category>
		<category><![CDATA[Smart Client]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/04/01/from-disconnected-scenarios-to-soa/</guid>
		<description><![CDATA[Jesse is bringing more context to the previous discussion around developing occasionally connected clients (OCC) by adding SOA to the mix. In his latest post, he points out that the messaging based solution I presented does not necessarily make the system Service-Oriented. Jesse states:
&#8220;In fact, without a proper service oriented architecture and messages that are [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><span lang="EN-US" style="mso-ansi-language: EN-US"><font face="Calibri" size="3">Jesse is bringing more context to the previous discussion around developing occasionally connected clients (OCC) by adding SOA to the mix. In his </font><a href="http://weblogs.asp.net/jezell/archive/2007/04/01/udi-on-soa-part-2.aspx"><font face="Calibri" color="#800080" size="3">latest post</font></a><font size="3"><font face="Calibri">, he points out that the messaging based solution I presented does not necessarily make the system Service-Oriented. Jesse states:<o:p></o:p></font></font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><em><span lang="EN-US" style="mso-ansi-language: EN-US"><font size="3"><font face="Calibri">&ldquo;In fact, without a proper service oriented architecture and messages that are constructed based on tasks instead of CRUD operations, you will end up in the same boat as if you hadn&#8217;t implemented this approach.&rdquo;<o:p></o:p></font></font></span></em></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><span lang="EN-US" style="mso-ansi-language: EN-US"><font size="3"><font face="Calibri">Let me be the first to agree.<o:p></o:p></font></font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><span lang="EN-US" style="mso-ansi-language: EN-US"><font face="Calibri" size="3">In no way did I intend to discuss SOA related issues in my </font><a href="http://udidahan.weblogs.us/2007/03/30/entity-framework-disconnected-problems-solutions/"><font face="Calibri" color="#800080" size="3">previous</font></a><font face="Calibri" size="3"> </font><a href="http://udidahan.weblogs.us/2007/03/31/tasks-messages-transactions-%e2%80%93-the-holy-trinity/"><font face="Calibri" size="3">posts</font></a><font size="3"><font face="Calibri">. Since I talk so much about SOA, and the use of the Bus Pattern and Asynchronous Messaging, I wanted to try to keep the discussion on OCC.<o:p></o:p></font></font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"><span lang="EN-US" style="mso-ansi-language: EN-US"><font size="3"><font face="Calibri">The main thing that I liked about Jesse&rsquo;s response was that he agreed that my solution &ldquo;solves some transaction issues&rdquo; which is what I was aiming for. I&rsquo;m going to be doing a separate series of posts on message design for SOA later, and would be happy to hear of anyone&rsquo;s experiences in that area. <o:p></o:p></font></font></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/04/01/from-disconnected-scenarios-to-soa/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Entity Framework: Disconnected Problems &amp; Solutions</title>
		<link>http://www.udidahan.com/2007/03/30/entity-framework-disconnected-problems-solutions/</link>
		<comments>http://www.udidahan.com/2007/03/30/entity-framework-disconnected-problems-solutions/#comments</comments>
		<pubDate>Fri, 30 Mar 2007 20:30:40 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[ADO.NET]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Smart Client]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/archives/438</guid>
		<description><![CDATA[Andres Aguiar points out an enormous change to the behavior of data access in tiered architectures that is coming with the ADO.NET Orcas Entity Framework. He sums it up nicely, “Basically, there is no disconnected mode.” He then goes on to talk about the ramifications of this:
“This basically means that if you plan to build [...]]]></description>
			<content:encoded><![CDATA[<p><P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"><SPAN lang=EN-US style="mso-ansi-language: EN-US"><FONT face=Calibri>Andres Aguiar points out </FONT><A href="http://weblogs.asp.net/aaguiar/archive/2007/03/30/ado-net-orcas-entity-framework-and-disconnected-operation.aspx"><FONT face=Calibri>an enormous change</FONT></A><FONT face=Calibri> to the behavior of data access in tiered architectures that is coming with the ADO.NET Orcas Entity Framework. He sums it up nicely, “Basically, there is no disconnected mode.” He then goes on to talk about the ramifications of this:</FONT></SPAN></P></p>
<p><P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"><I><SPAN lang=EN-US style="mso-ansi-language: EN-US"><FONT face=Calibri>“This basically means that if you plan to build a multi-tier application with ADO.NET Orcas in the middle tier, you will need to hack your own change tracking mechanism in the client, send the whole changeset, and apply it in the middle tier. From this point of view, it&#8217;s a huge step backwards, as that&#8217;s something we already have with DataSets today.”<o:p></o:p></FONT></SPAN></I></P></p>
<p><P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"><SPAN lang=EN-US style="mso-ansi-language: EN-US"><FONT face=Calibri>I do quite a bit of work on large-scale distributed systems, some that could even be called “multi-tier”, but I really don’t like that term. I’ve got to tell you, I’m not that worried. I could say that it’s because I’m using an object/relational mapping tool, but then again, the Entity Framework is supposed to be that too. It also might be because </FONT><A href="http://udidahan.weblogs.us/2006/11/21/re-datasets/"><FONT face=Calibri>I don’t use DataSets that much today anyway</FONT></A><FONT face=Calibri>, but that begs Andres’ question – did I develop my own change-tracking mechanism on the client?<o:p></o:p></FONT></SPAN></P></p>
<p><P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"><SPAN lang=EN-US style="mso-ansi-language: EN-US"><FONT face=Calibri>The answer lies in the second part of Andres’ question, I don’t “send the whole changeset, and apply it in the middle tier”. I have an </FONT><A href="http://udidahan.weblogs.us/2007/03/28/podcast-datasets-web-services/"><FONT face=Calibri>entire podcast</FONT></A><FONT face=Calibri> up on why I don’t think that that’s a good idea, specifically around Web Services and SOA, but it’s broadly applicable. However, the question remains, what do we do about the client side?<o:p></o:p></FONT></SPAN></P></p>
<p><P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"><SPAN lang=EN-US style="mso-ansi-language: EN-US"><FONT face=Calibri>Just over a year ago, me and </FONT><A href="http://blog.springframework.com/arjen/"><FONT face=Calibri>Arjen Poutsma</FONT></A><FONT face=Calibri> (of Spring fame) had a </FONT><A href="http://udidahan.weblogs.us/2007/01/16/thoughts-about-usability/"><FONT face=Calibri>discussion</FONT></A><FONT face=Calibri> about this exact topic at the Software Architecture Workshop in beautiful Cortina, Italy. Here’s the important part:<o:p></o:p></FONT></SPAN></P></p>
<p><P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"><SPAN lang=EN-US style="mso-ansi-language: EN-US"><FONT face=Calibri>I think it started by me saying that services should not expose CRUD style operations. Arjen countered by mentioning that most user interfaces in line-of-business applications exposed the same model to the user by having them fill out data in grids. My retort to that was that while humans can get used to almost anything as long as it’s consistent, that doesn’t mean that it is a good solution. In the systems that I work on there is usually an HCI (human-computer interaction) person on the project who designs the UI, mostly around the tasks they perform. These tasks often corresponded very well to the coarse-grained messages we employed in terms of SOA. We finally agreed that the successor of SOA would be TOA (Task-Oriented Architecture) in its aggregation of client-side aspects to the already server-centric principles of SOA.<o:p></o:p></FONT></SPAN></P></p>
<p><P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"><SPAN lang=EN-US style="mso-ansi-language: EN-US"><FONT face=Calibri>As a concrete example, instead of updating customer data in a grid showing everything laid out flat, users would activate tasks like “Change address”, or “Update marital status”. The form shown would contain only the relevant data to be updated – no need to perform “change tracking”, it is perfectly clear what data needs to be sent. Furthermore, the intent behind the changed data would be sent as well – the server wouldn’t apply the data generically “in the middle tier”. Rather, the current customer data would be retrieved as a part of the customer object, and the appropriate method called upon it (ChangeAddress, or UpdateMaritalStatus) with the relevant data.<o:p></o:p></FONT></SPAN></P></p>
<p><P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"><SPAN lang=EN-US style="mso-ansi-language: EN-US"><FONT face=Calibri>I actually view this change in the Entity Framework as a step forward, it’s like taking off the training wheels. I’m positive that most developers will be able to make the change and move to these more advanced architectures.<o:p></o:p></FONT></SPAN></P></p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/03/30/entity-framework-disconnected-problems-solutions/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Something huge passed under the radar</title>
		<link>http://www.udidahan.com/2005/06/20/something-huge-passed-under-the-radar/</link>
		<comments>http://www.udidahan.com/2005/06/20/something-huge-passed-under-the-radar/#comments</comments>
		<pubDate>Tue, 21 Jun 2005 05:13:54 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Smart Client]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://wp_630.weblogs.us/archives/199</guid>
		<description><![CDATA[<p>Why isn't everybody talking about http.sys being separated from IIS? Desktops running XP can accept and respond to http requests. This means web services. Using WSE2+ and you get SoapListeners, "out of the box".
</p><p>
If this still isn't sinking in, it means you can get asynchronous callbacks with webservices by using the Return Address pattern without fiddling with protocols and polling.
</p><p>
Lets look at a scenario: Smart client sends a soap message to a service endpoint. In this header of that message (possibly using WS-Addressing but not necessarily) is the return address - where the client will be listening for the response. When the service finishes processing the message at some time in the future, it simply sends the response to the endpoint indicated by the return address field in the header. Asynchronous, one-way web services with callbacks.
</p><p>
Why isn't Microsoft hyping this?<BR />
No idea.]]></description>
			<content:encoded><![CDATA[<p>Why isn&#8217;t everybody talking about http.sys being separated from IIS? Desktops running XP can accept and respond to http requests. This means web services. Using WSE2+ and you get SoapListeners, &#8220;out of the box&#8221;.</p>
<p>If this still isn&#8217;t sinking in, it means you can get asynchronous callbacks with webservices by using the Return Address pattern without fiddling with protocols and polling.</p>
<p>Lets look at a scenario: Smart client sends a soap message to a service endpoint. In this header of that message (possibly using WS-Addressing but not necessarily) is the return address &#8211; where the client will be listening for the response. When the service finishes processing the message at some time in the future, it simply sends the response to the endpoint indicated by the return address field in the header. Asynchronous, one-way web services with callbacks.</p>
<p>Why isn&#8217;t Microsoft hyping this?<br />
No idea.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2005/06/20/something-huge-passed-under-the-radar/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

