<?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>simonpena.com &#187; Command Pattern</title>
	<atom:link href="http://simonpena.com/blog/tag/command-pattern/feed/" rel="self" type="application/rss+xml" />
	<link>http://simonpena.com/blog</link>
	<description>Una mezcla heterogénea de tecnología y desvaríos</description>
	<lastBuildDate>Sun, 13 May 2012 12:37:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Undo, redo support using patterns</title>
		<link>http://simonpena.com/blog/proyectos/pennybank/undo-redo-support-using-patterns/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=undo-redo-support-using-patterns</link>
		<comments>http://simonpena.com/blog/proyectos/pennybank/undo-redo-support-using-patterns/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 17:49:12 +0000</pubDate>
		<dc:creator>Simón</dc:creator>
				<category><![CDATA[Pennybank]]></category>
		<category><![CDATA[Command Pattern]]></category>
		<category><![CDATA[Composite Pattern]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[implementation]]></category>
		<category><![CDATA[Template method Pattern]]></category>

		<guid isPermaLink="false">http://pennybank.wordpress.com/?p=65</guid>
		<description><![CDATA[More report progress regarding undo, redo and execute using design patterns.<div class="addthis_toolbox addthis_default_style " addthis:url='http://simonpena.com/blog/proyectos/pennybank/undo-redo-support-using-patterns/' addthis:title='Undo, redo support using patterns '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></description>
			<content:encoded><![CDATA[<p>This Easter Week has been very productive. Although I didn't upload the screenshots as I said, I've made several interesting improvements.</p>
<ul>
<li>The delete menu item changes according to the current user interface selection. If an account is selected, it displays <em>delete account</em>. If an user is selected, it displays <em>delete user</em>, and if an account operation is selected, it displays <em>delete account operation</em>.</li>
<li>It is possible to undo/redo the actions made. The major improvement I pointed out on the previous post is almost done, so you can reverse the addition, edition and deletion of users, accounts and account operations.</li>
</ul>
<p>I've made a new hierarchy in the controller layer. I created the interface <a title="UIAction.java" href="http://code.google.com/p/pennybank/source/browse/trunk/src/main/java/com/googlecode/pennybank/swing/controller/actions/UIAction.java" target="_blank">UIAction</a>, with methods <em>execute</em>, <em>undo</em>, <em>redo</em> and <em>getName</em>. I created an abstract implementation, <a title="GenericAction.java" href="http://code.google.com/p/pennybank/source/browse/trunk/src/main/java/com/googlecode/pennybank/swing/controller/actions/GenericAction.java" target="_blank">GenericAction</a>, where I made <em>final</em> those methods -to avoid the concrete classes reimplementing them-, calling <em>doExecute</em>, <em>doUndo,</em> <em>doRedo</em> and <em>doGetName</em> (which currently doesn't make much sense), followed by a call to update (a private method which updates the information displayed on the main window).</p>
<p>The do<em>Wathever</em> methods are <em>protected</em> and <em>abstract</em>, so the actions extending GenericAction must override them. This way, each action implements its own behavior for that methods, but at the same time complying with the generic behavior without the an explicit call to <em>super</em>. It follows the <a title="Template method pattern" href="http://en.wikipedia.org/wiki/Template_method_pattern" target="_blank">Template method pattern</a>.</p>
<p>Besides, I made a <a title="CompositeAction.java" href="http://code.google.com/p/pennybank/source/browse/trunk/src/main/java/com/googlecode/pennybank/swing/controller/actions/CompositeAction.java" target="_blank">CompositeAction</a> class, following the <a title="Composite pattern" href="http://en.wikipedia.org/wiki/Composite_pattern" target="_blank">Composite pattern</a>, so several actions can be grouped into another.</p>
<p>This way, all the defined actions are commands, and the application itself has the responsibility of executing them. Whenever an action is executed, it is stored in an <em>undoable actions stack</em>, and its name is set in the edit menu, so you can read "Undo <em>actionName</em>". If you undo the action, the application takes it out from the stack, invokes its <em>undo </em>method, and adds it to the <em>redoable actions stack</em>. After that, its name will appear in the edit menu, displaying "Redo <em>actionName</em>". Again, if you redo the action, the application takes it out from that stack and invokes its <em>redo</em> method, adding it again to the <em>undoable actions stack</em>. And over and over again (as far as it is well implemented).</p>
<div class="addthis_toolbox addthis_default_style " addthis:url='http://simonpena.com/blog/proyectos/pennybank/undo-redo-support-using-patterns/' addthis:title='Undo, redo support using patterns '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></content:encoded>
			<wfw:commentRss>http://simonpena.com/blog/proyectos/pennybank/undo-redo-support-using-patterns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Keep working hard</title>
		<link>http://simonpena.com/blog/proyectos/pennybank/keep-working-hard/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=keep-working-hard</link>
		<comments>http://simonpena.com/blog/proyectos/pennybank/keep-working-hard/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 01:02:52 +0000</pubDate>
		<dc:creator>Simón</dc:creator>
				<category><![CDATA[Pennybank]]></category>
		<category><![CDATA[Command Pattern]]></category>
		<category><![CDATA[embedded database]]></category>
		<category><![CDATA[H2 database]]></category>
		<category><![CDATA[implementation]]></category>

		<guid isPermaLink="false">http://pennybank.wordpress.com/?p=63</guid>
		<description><![CDATA[Some progress report<div class="addthis_toolbox addthis_default_style " addthis:url='http://simonpena.com/blog/proyectos/pennybank/keep-working-hard/' addthis:title='Keep working hard '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></description>
			<content:encoded><![CDATA[<p>It's been a while since the last post, and some improvements have been made. I've added a context menu both to the navigation panel and the account operation table, and it is now possible to rename, edit and delete accounts, and edit and delete account operations. I've fixed the account operations table filters, so you can search within the comments and categories (or both) of the account operations. The field to be searched is selected in a search text box just like iTunes'.</p>
<p>The menu bar isn't completed yet: there are several operations which can't be accessed from there. But as the listeners and actions are made for the context menu, the work left is reduced to bind those actions to the main menu items.</p>
<p>The next major change involves re-factoring some of the actions, so the <a title="Command pattern" href="http://en.wikipedia.org/wiki/Command_pattern" target="_blank">Command Pattern</a> can be introduced: support for undo and redo should is the next target.</p>
<p>There's still another thing I have to put hours in: improving the application installation and configuration. Right now it involves downloading Maven, MySQL and JTA, and installing and configuring them. Several weeks ago I found <a title="H2 Database" href="http://www.h2database.com/" target="_blank">H2 Database</a>, and how easy it was to install and use it. I think it would be a lot easier for the final user to have his data in an embedded database, so the task left for me is to figure how to select the database placement, choose if that placement is a permanent one or can be changed even on runtime, and if it would even be possible to change between an embedded database or a server one.</p>
<p>I'm not sure which option should I prioritize... We'll see. And I'll upload some screenshots someday within this week.</p>
<div class="addthis_toolbox addthis_default_style " addthis:url='http://simonpena.com/blog/proyectos/pennybank/keep-working-hard/' addthis:title='Keep working hard '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></content:encoded>
			<wfw:commentRss>http://simonpena.com/blog/proyectos/pennybank/keep-working-hard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

