Powered by Twitter Tools.

July 2006
M T W T F S S
« Jun   Aug »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Chris Donnan : Programming - Brooklyn Style

software, trading, family, fun

MVP, Commands and Actions - as they are happening in Spring.net Desktop Application Framework

I have been working to get some stuff together for a decent 1st release of the Spring .Net Desktop Application Framework - Spring.net DAF. I wanted to chat a bit here about the MVP (model view presenter), commands and actions.

In the past - I have seen some ‘fat controllers’ in .net Winforms apps. People try to ‘do the right thing’ and do an MV(C/P) - and seperate the view stuff from the control flow and the commands or tasks. After going through this many-o-time, I believe I have been able to model out a good set of constructs.

  • View - tries to perform Actions via it’s Presenter (user controls for the most part)
  • Presenter - has buckets of Commands and a View
  • Commands
    • Presenter Commands - automates the view and manages ‘non UI related tasks’ including background tasks.
    • Background Commands -reusable  - async units-of-work

The container

First and foremost - The UI Application Container should inject any needed dependencies into the UI. This includes bulding up the presenter, commands, etc. that a view is expecting.
View

<meta content="OpenOffice.org 2.0 (Linux)" name="GENERATOR" /><meta content="chris donnan" name="AUTHOR" /><meta content="20060705;264900" name="CREATED" /><meta content="16010101;0" name="CHANGED" /><br /> <style type="text/css"> <!-- @page { size: 8.5in 11in; margin: 0.79in } P { margin-bottom: 0.08in } --></style> <p>These are your friendly UserControls and forms. In essence, the goal is to keep the Views - dumb. The view should basically have an API so it can be implemented by person A (theoretically) and automated by some presenter yet to be implemented. Here is a simple button click - asking the presenter to handle an action being requested. The view can pass parameters with the Action in a CommandParameter list. These are typed via generics.<br /> <img alt="callAction.png" id="image170" src="http://chrisdonnan.com/blog/wp-content/uploads/2006/07/callAction.png" /></p> <p><span style="font-weight: bold">Presenter</span></p> <p>The Presenter is then free to do whatever it needs to - and then automate the View as needed.</p> <p>The presenter has it’s commands wired up via spring - like so….</p> <p><img alt="presenterCommandWiring.png" id="image171" src="http://chrisdonnan.com/blog/wp-content/uploads/2006/07/presenterCommandWiring.png" /></p> <p>This means that you can add in commands, change the implementation of a command, etc. Often - a ‘generic’ presenter can be used - that just wires commands to a view. These Presenter Commands have access to the Presenter and the View to do whatever they need to do. This means that all UI Operations can be canned up in a command - a single unit of work… nice, testable.</p> <p style="font-weight: bold">Commands</p> <p style="font-weight: bold"><span style="font-weight: normal">Here</span> <span style="font-weight: normal">is an admittedly useless command</span>:</p> <p style="font-weight: bold"><img alt="presenterCommand2.png" id="image173" src="http://chrisdonnan.com/blog/wp-content/uploads/2006/07/presenterCommand2.png" /></p> <p>This command is just wired to a name via spring. It does what it needs - in this case - just dealing with the view. In this ‘do execution’ method (a template method) - you could do whatever. This PresenterCommand class derives from PresenterCommand - a base class that does the basic PresenterCommand implementation - there is also a BackgroundPresenterCommand that could be derived from - providing more template methods - that would do ‘background work’.</p> <p style="font-weight: bold"><span style="font-weight: normal">Also note this command is ‘view cognisant’. There are also - in my way of thinking - non-view-cognisant background commands. I have called these ‘units of work’ in the past. These are typically called - in this model - in the PresenterCommands.</span></p> <p style="font-weight: bold">Command Parameters</p> <p style="font-weight: bold"><span style="font-weight: normal">Note the simple use of CommandParameters here too. This is a simple example of just getting the value of an expected parameter passed to this command via The Action’s CommandParameters.  The Command/ Command Parameters are loosely modeled off of the ADO Command/ Sql Parameters. My goal was to try to give metaphor that ‘feels normal’ to developers. I think the  level of usage that the ADO Commands have provide a  good baseline for usage.</span></p> <p style="font-weight: bold"><span style="font-weight: normal">This is just a quicky intro to what has been going on. Hopefully I will find the time to getting this stuff out there ASAP.</span></p> <p style="font-weight: bold"><span style="font-weight: normal">My best;<br /> Chris<br /> </span></p> <div class="sociable"> <div class="sociable_tagline"> <b>Share and Enjoy:</b> </div> <ul> <li><a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fchrisdonnan.com%2Fblog%2F2006%2F07%2F05%2Fmvp-commands-and-actions-as-they-are-happening-in-springnet-desktop-application-framework%2F&title=MVP%2C%20Commands%20and%20Actions%20-%20as%20they%20are%20happening%20in%20Spring.net%20Desktop%20Application%20Framework" title="del.icio.us"><img src="http://chrisdonnan.com/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li> <li><a rel="nofollow" href="" title="digg"><img src="http://chrisdonnan.com/blog/wp-content/plugins/sociable/images/" title="digg" alt="digg" class="sociable-hovers" /></a></li> <li><a rel="nofollow" href="http://www.blinkbits.com/bookmarklets/save.php?v=1&source_url=http%3A%2F%2Fchrisdonnan.com%2Fblog%2F2006%2F07%2F05%2Fmvp-commands-and-actions-as-they-are-happening-in-springnet-desktop-application-framework%2F&title=MVP%2C%20Commands%20and%20Actions%20-%20as%20they%20are%20happening%20in%20Spring.net%20Desktop%20Application%20Framework&body=MVP%2C%20Commands%20and%20Actions%20-%20as%20they%20are%20happening%20in%20Spring.net%20Desktop%20Application%20Framework" title="blinkbits"><img src="http://chrisdonnan.com/blog/wp-content/plugins/sociable/images/blinkbits.png" title="blinkbits" alt="blinkbits" class="sociable-hovers" /></a></li> <li><a rel="nofollow" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&Url=http%3A%2F%2Fchrisdonnan.com%2Fblog%2F2006%2F07%2F05%2Fmvp-commands-and-actions-as-they-are-happening-in-springnet-desktop-application-framework%2F&Title=MVP%2C%20Commands%20and%20Actions%20-%20as%20they%20are%20happening%20in%20Spring.net%20Desktop%20Application%20Framework" title="BlinkList"><img src="http://chrisdonnan.com/blog/wp-content/plugins/sociable/images/blinklist.png" title="BlinkList" alt="BlinkList" class="sociable-hovers" /></a></li> <li><a rel="nofollow" href="http://blogmarks.net/my/new.php?mini=1&simple=1&url=http%3A%2F%2Fchrisdonnan.com%2Fblog%2F2006%2F07%2F05%2Fmvp-commands-and-actions-as-they-are-happening-in-springnet-desktop-application-framework%2F&title=MVP%2C%20Commands%20and%20Actions%20-%20as%20they%20are%20happening%20in%20Spring.net%20Desktop%20Application%20Framework" title="blogmarks"><img src="http://chrisdonnan.com/blog/wp-content/plugins/sociable/images/blogmarks.png" title="blogmarks" alt="blogmarks" class="sociable-hovers" /></a></li> <li><a rel="nofollow" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fchrisdonnan.com%2Fblog%2F2006%2F07%2F05%2Fmvp-commands-and-actions-as-they-are-happening-in-springnet-desktop-application-framework%2F&=MVP%2C%20Commands%20and%20Actions%20-%20as%20they%20are%20happening%20in%20Spring.net%20Desktop%20Application%20Framework" title="YahooMyWeb"><img src="http://chrisdonnan.com/blog/wp-content/plugins/sociable/images/yahoomyweb.png" title="YahooMyWeb" alt="YahooMyWeb" class="sociable-hovers" /></a></li> <li><a rel="nofollow" href="http://www.connotea.org/addpopup?continue=confirm&uri=http%3A%2F%2Fchrisdonnan.com%2Fblog%2F2006%2F07%2F05%2Fmvp-commands-and-actions-as-they-are-happening-in-springnet-desktop-application-framework%2F&title=MVP%2C%20Commands%20and%20Actions%20-%20as%20they%20are%20happening%20in%20Spring.net%20Desktop%20Application%20Framework" title="connotea"><img src="http://chrisdonnan.com/blog/wp-content/plugins/sociable/images/connotea.png" title="connotea" alt="connotea" class="sociable-hovers" /></a></li> <li><a rel="nofollow" href="http://de.lirio.us/rubric/post?uri=http%3A%2F%2Fchrisdonnan.com%2Fblog%2F2006%2F07%2F05%2Fmvp-commands-and-actions-as-they-are-happening-in-springnet-desktop-application-framework%2F;title=MVP%2C%20Commands%20and%20Actions%20-%20as%20they%20are%20happening%20in%20Spring.net%20Desktop%20Application%20Framework;when_done=go_back" title="De.lirio.us"><img src="http://chrisdonnan.com/blog/wp-content/plugins/sociable/images/delirious.png" title="De.lirio.us" alt="De.lirio.us" class="sociable-hovers" /></a></li> <li><a rel="nofollow" href="http://cgi.fark.com/cgi/fark/edit.pl?new_url=http%3A%2F%2Fchrisdonnan.com%2Fblog%2F2006%2F07%2F05%2Fmvp-commands-and-actions-as-they-are-happening-in-springnet-desktop-application-framework%2F&new_comment=MVP%2C%20Commands%20and%20Actions%20-%20as%20they%20are%20happening%20in%20Spring.net%20Desktop%20Application%20Framework&new_comment=Chris+Donnan+%3A+Programming+-+Brooklyn+Style+software%2C+trading%2C+family%2C+fun&linktype=Misc" title="Fark"><img src="http://chrisdonnan.com/blog/wp-content/plugins/sociable/images/fark.png" title="Fark" alt="Fark" class="sociable-hovers" /></a></li> <li><a rel="nofollow" href="http://www.furl.net/storeIt.jsp?u=http%3A%2F%2Fchrisdonnan.com%2Fblog%2F2006%2F07%2F05%2Fmvp-commands-and-actions-as-they-are-happening-in-springnet-desktop-application-framework%2F&t=MVP%2C%20Commands%20and%20Actions%20-%20as%20they%20are%20happening%20in%20Spring.net%20Desktop%20Application%20Framework" title="Furl"><img src="http://chrisdonnan.com/blog/wp-content/plugins/sociable/images/furl.png" title="Furl" alt="Furl" class="sociable-hovers" /></a></li> <li><a rel="nofollow" href="http://reddit.com/submit?url=http%3A%2F%2Fchrisdonnan.com%2Fblog%2F2006%2F07%2F05%2Fmvp-commands-and-actions-as-they-are-happening-in-springnet-desktop-application-framework%2F&title=MVP%2C%20Commands%20and%20Actions%20-%20as%20they%20are%20happening%20in%20Spring.net%20Desktop%20Application%20Framework" title="Reddit"><img src="http://chrisdonnan.com/blog/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li> <li><a rel="nofollow" href="http://www.scuttle.org/bookmarks.php/maxpower?action=add&address=http%3A%2F%2Fchrisdonnan.com%2Fblog%2F2006%2F07%2F05%2Fmvp-commands-and-actions-as-they-are-happening-in-springnet-desktop-application-framework%2F&title=MVP%2C%20Commands%20and%20Actions%20-%20as%20they%20are%20happening%20in%20Spring.net%20Desktop%20Application%20Framework" title="description"><img src="http://chrisdonnan.com/blog/wp-content/plugins/sociable/images/scuttle.png" title="description" alt="description" class="sociable-hovers" /></a></li> <li><a rel="nofollow" href="http://www.shadows.com/features/tcr.htm?url=http%3A%2F%2Fchrisdonnan.com%2Fblog%2F2006%2F07%2F05%2Fmvp-commands-and-actions-as-they-are-happening-in-springnet-desktop-application-framework%2F&title=MVP%2C%20Commands%20and%20Actions%20-%20as%20they%20are%20happening%20in%20Spring.net%20Desktop%20Application%20Framework" title="Shadows"><img src="http://chrisdonnan.com/blog/wp-content/plugins/sociable/images/shadows.png" title="Shadows" alt="Shadows" class="sociable-hovers" /></a></li> <li><a rel="nofollow" href="http://smarking.com/editbookmark/?url=http%3A%2F%2Fchrisdonnan.com%2Fblog%2F2006%2F07%2F05%2Fmvp-commands-and-actions-as-they-are-happening-in-springnet-desktop-application-framework%2F&title=MVP%2C%20Commands%20and%20Actions%20-%20as%20they%20are%20happening%20in%20Spring.net%20Desktop%20Application%20Framework" title="Smarking"><img src="http://chrisdonnan.com/blog/wp-content/plugins/sociable/images/smarking.png" title="Smarking" alt="Smarking" class="sociable-hovers" /></a></li> <li><a rel="nofollow" href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fchrisdonnan.com%2Fblog%2F2006%2F07%2F05%2Fmvp-commands-and-actions-as-they-are-happening-in-springnet-desktop-application-framework%2F&title=MVP%2C%20Commands%20and%20Actions%20-%20as%20they%20are%20happening%20in%20Spring.net%20Desktop%20Application%20Framework" title="Spurl"><img src="http://chrisdonnan.com/blog/wp-content/plugins/sociable/images/spurl.png" title="Spurl" alt="Spurl" class="sociable-hovers" /></a></li> <li><a rel="nofollow" href="http://tailrank.com/share/?text=&link_href=http%3A%2F%2Fchrisdonnan.com%2Fblog%2F2006%2F07%2F05%2Fmvp-commands-and-actions-as-they-are-happening-in-springnet-desktop-application-framework%2F&title=MVP%2C%20Commands%20and%20Actions%20-%20as%20they%20are%20happening%20in%20Spring.net%20Desktop%20Application%20Framework" title="TailRank"><img src="http://chrisdonnan.com/blog/wp-content/plugins/sociable/images/tailrank.png" title="TailRank" alt="TailRank" class="sociable-hovers" /></a></li> <li><a rel="nofollow" href="http://wists.com/s.php?c=&r=http%3A%2F%2Fchrisdonnan.com%2Fblog%2F2006%2F07%2F05%2Fmvp-commands-and-actions-as-they-are-happening-in-springnet-desktop-application-framework%2F&title=MVP%2C%20Commands%20and%20Actions%20-%20as%20they%20are%20happening%20in%20Spring.net%20Desktop%20Application%20Framework" title="Wists"><img src="http://chrisdonnan.com/blog/wp-content/plugins/sociable/images/wists.png" title="Wists" alt="Wists" class="sociable-hovers sociable_wists" /></a></li> </ul> </div> <!-- You can start editing here. --> <!-- If comments are open, but there are no comments. --> <h2 id="respond">Comment on this post below</h2> <p>You must be <a href="http://chrisdonnan.com/blog/wp-login.php?redirect_to=http://chrisdonnan.com/blog/2006/07/05/mvp-commands-and-actions-as-they-are-happening-in-springnet-desktop-application-framework/">logged in</a> to post a comment.</p> <br><p> You can <a href="#respond">leave a response</a>, or <a href="http://chrisdonnan.com/blog/2006/07/05/mvp-commands-and-actions-as-they-are-happening-in-springnet-desktop-application-framework/trackback/">trackback</a> from your own site. </p> <div> <br> <div class="align-left"><h3>« <a href="http://chrisdonnan.com/blog/2006/07/05/a-few-good-reads/">A few good reads</a></h3></div> <div class="align-right"><h3> <a href="http://chrisdonnan.com/blog/2006/07/06/db4o-book/">db4o book … and a few others</a> »</h3></div> </div> </div> <!-- CLOSES ELVGREN POST DIV --> <br> </div> <div id="footer"> Few things in life are free: <a href="http://www.wordpress.org">Wordpress</a> is, and this is proudly powered by version 1.5 of it.<br> 29 marching ants built this page in 0.642 seconds. <a href="http://www.opensource.org/licenses/gpl-license.php" title="Released under the GPL - visit the link if you don't know what it is. Duh...">© 2002-2005</a>.<br> <a href="http://www.secretweaponlabs.com/words">Elvgren 1.0</a> by Denis Somar of <a href="http://www.secretweaponlabs.com">Secret Weapon Labs</a> </div> </div> </body> </html>