<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>DM-V-VM part 3: A sample DataModel</title><link>http://blogs.msdn.com/dancre/archive/2006/07/26/dm-v-vm-part-3-a-sample-datamodel.aspx</link><description>In part 2 , I showed a base class for DataModels. In this post, I will describe a sample implementation. For this sample, I'll use a DataModel that represents a stock. The model will be in charge of asynchronously fetching the stock quote and making it's</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>DM-V-VM part 4: Unit testing the DataModel</title><link>http://blogs.msdn.com/dancre/archive/2006/07/26/dm-v-vm-part-3-a-sample-datamodel.aspx#679871</link><pubDate>Thu, 27 Jul 2006 08:27:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:679871</guid><dc:creator>Dan Crevier's Blog</dc:creator><description>In part 3, I showed code for StockModel, a DataModel for stocks. On the Max team, we are big believers...</description></item><item><title>re: DM-V-VM part 3: A sample DataModel</title><link>http://blogs.msdn.com/dancre/archive/2006/07/26/dm-v-vm-part-3-a-sample-datamodel.aspx#690191</link><pubDate>Sun, 06 Aug 2006 20:13:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:690191</guid><dc:creator>Joe</dc:creator><description>Not sure about the way you tied the retreival logic with the model state. &lt;br&gt;I would preferred you model the data in one class (and collections of that data) and then model the service that populates that data in another. &amp;nbsp;This way you separate the data away from performing a function on that data. &amp;nbsp;Even worse this logic retreives just one quote - what happens when you want to retreive a portfolio of quotes. &amp;nbsp;You would need to put this logic into the Quote container.&lt;br&gt;&lt;br&gt;You could argue that different sources of data would all support the same interface - IStockQuote. &amp;nbsp;It just seems to be better practice to force the boundary between the retrieval of the data and the state itself to be more explicit. &amp;nbsp;It's not common practice now to derive from ADO's DataSet and add your database functions in there. &amp;nbsp;In general seperating state from program logic lends itself to more scalable solutions.</description></item><item><title>re: DM-V-VM part 3: A sample DataModel</title><link>http://blogs.msdn.com/dancre/archive/2006/07/26/dm-v-vm-part-3-a-sample-datamodel.aspx#691060</link><pubDate>Mon, 07 Aug 2006 19:14:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:691060</guid><dc:creator>dancre</dc:creator><description>Good feedback. It would probably have been better to also show a factored out StockQuote class that just contains the raw data. I think that's a more typical pattern. The quote provider can have the logic to batch up queries, but it really hasn't been given enough information to do so properly in this case.&lt;br&gt;&lt;br&gt;The big advantage to having the model control when to retrieve the data is that it helps with virtualization. However, the way I wrote it in this example, you don't get that advantage. Hold on and I'll show a more realistic example where we only fetch the expensive data when the DataModel is visible in the UI. This is a key piece of the pattern that I left out.</description></item><item><title>re: DM-V-VM part 3: A sample DataModel</title><link>http://blogs.msdn.com/dancre/archive/2006/07/26/dm-v-vm-part-3-a-sample-datamodel.aspx#736302</link><pubDate>Sat, 02 Sep 2006 10:59:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:736302</guid><dc:creator>Marko Vuksanovic</dc:creator><description>I've noticed that in the sample here you retreive the stock information inside a thread.... What happens with the following scenario:&lt;br&gt;&lt;br&gt;You need to fetch a photo prom the internet (let's say a larg photo that it will take at leaset 10 secs to download). That image is loaded into a BitmapImaga object. This means that inside a thread you need to catch the DownloadCompleted event.... But if the thread is completed before the event is fired it will be destroyed and you will not have the image stored in that object... So how would you suggest to have that event captured inside the thread, so that the thread is not destroyed before the event is fired.... Or I am missing something!?</description></item><item><title>re: DM-V-VM part 3: A sample DataModel</title><link>http://blogs.msdn.com/dancre/archive/2006/07/26/dm-v-vm-part-3-a-sample-datamodel.aspx#739744</link><pubDate>Mon, 04 Sep 2006 19:00:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:739744</guid><dc:creator>dancre</dc:creator><description>If you are doing an expensive operation like fetching an image over the network, there are basically two approaches. One is to do it synchronously on a background thread and the other is to use the asynchronous APIs. If you are using the asynchronous APIs, there's no need to set up your own background thread. Just dispatch the results to the UI thread in your DownloadCompleted event.</description></item><item><title>WPF Patterns</title><link>http://blogs.msdn.com/dancre/archive/2006/07/26/dm-v-vm-part-3-a-sample-datamodel.aspx#774335</link><pubDate>Wed, 27 Sep 2006 23:31:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:774335</guid><dc:creator>Bryant Likes's Blog</dc:creator><description>If you're doing WPF development, you really need to check out Dan Crevier 's series on DataModel-View-ViewModel.</description></item><item><title>DataModel-View-ViewModel pattern series</title><link>http://blogs.msdn.com/dancre/archive/2006/07/26/dm-v-vm-part-3-a-sample-datamodel.aspx#818057</link><pubDate>Thu, 12 Oct 2006 05:00:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:818057</guid><dc:creator>Dan Crevier's Blog</dc:creator><description>&lt;p&gt;I thought I should add a post with the full list of posts in the D-V-VM pattern. They are: DataModel-View-ViewModel&lt;/p&gt;
</description></item><item><title>DM-V-VM part 4: Unit testing the DataModel</title><link>http://blogs.msdn.com/dancre/archive/2006/07/26/dm-v-vm-part-3-a-sample-datamodel.aspx#1426506</link><pubDate>Sun, 07 Jan 2007 07:39:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1426506</guid><dc:creator>Dan Crevier's Blog</dc:creator><description>&lt;p&gt;In part 3 , I showed code for StockModel, a DataModel for stocks. On the Max team, we are big believers&lt;/p&gt;
</description></item></channel></rss>