[jsword-devel] i18n and Actions

DM Smith jsword-devel@crosswire.org
Fri, 02 Apr 2004 18:38:31 -0500


Andy, if all that an action provided was a callback mechanism (i.e. 
actionPerformed), you would be right that your solution is comparable.

>From my perspective, that is not why one would ever think of using an 
action. The value in having an action is to share it.

Lets say that an application represents "Save" as a choice on an Edit menu, 
on a right click popup and on a toolbar. If there were a requirement that 
Save is enabled only when there is something to save.

With this requirement we can examine the two different solutions:
Building each widget separately means that each widget needs to be found 
when the condition occurs that requires it to be enabled/disabled. These 
widgets may be held by entirely different objects. Finding them will require 
a bunch of member variables (one for each widget) and traversal methods to 
get from the place that the condition needing a state change is identified 
to the objects holding the widgets.

With an action being shared by all three widgets, enabling/disabling the 
action sets the state on all the widgets using it. The only trick is to find 
the one action. By using an ActionFactory that has a static lookup mechanism 
this is easy.

Likewise if you have a requirement that the label for the shared operation 
changes in all places that that operation occurs, it takes a lot of code to 
do it without Actions. With an action, you just putValue(Action.NAME, 
newname) and all the labels are updated.

Same goes for tooltips.

I think the memory cost for a couple dozen actions is a small price to pay. 
Especially when the application search index is so large.

>From: Aleksander Rozman - Andy <andy@triera.net>
>Reply-To: jsword-devel@crosswire.org
>To: jsword-devel@crosswire.org
>Subject: Re: [jsword-devel] i18n and Actions
>Date: Sat, 03 Apr 2004 00:59:22 +0200
>
>At 2.4.2004, you wrote:
>
>>Hi Andy,
>>
>>I think the biggest difference between our coding styles is that you 
>>prefer a minimalist approach, but my approach aims to be more generic.
>>
>>The reason I tend toward a more generic approach is that usually you can 
>>turn a generic but slow solution into a faster minimalist solution, but it 
>>is harder to generalize a highly tuned minimalist solution, however I can 
>>understand that this approach is frustrating for developers that need to 
>>get at the more minimalist approach during development.
>>
>>The 2 examples in your mail (Actions and I18N) both fit into this pattern. 
>>We can easily run some eclpise refactorings or ant macros across the 
>>JSword source to convert the generic Msg i18n solution into a minimalist 
>>String based i18n solution, but the reverse is not possible. Similar 
>>arguments work for JSwordGUI vs. Desktop.
>>
>>There are plenty of things we can do to make JSword faster, but for me 
>>making it function properly is more important right now so my vote is to 
>>continue to be generalist until the cries of "xyz is too slow for me" 
>>drown out the cries of "xyz doesn't work".
>>
>>Sorry to be a stick-in-the-mud.
>>
>>Joe.
>
>Really? What does your actions have that mine don't? Nothing they are same, 
>except mine uses less memory and your uses much more? Functionality is the 
>same...
>
>Andy
>
>
>>Aleksander Rozman - Andy wrote:
>>
>>>At 2.4.2004, you wrote:
>>...
>>>I have already told that this way of creating Actions is not good... When 
>>>you create application you should use as little as possible action 
>>>classes, but instead implement one ActionListener for more actions. Here 
>>>is sample how I did it (I started makeing changes on JSword some time 
>>>ago). Also included is my file for I18N..., which is used by this class.
>>>I also mentioned about I18N, but I couldn't convince the boss that my way 
>>>is better even if it's used by almost all other java programmers...
>>>Andy
>>
>>
>>_______________________________________________
>>jsword-devel mailing list
>>jsword-devel@crosswire.org
>>http://www.crosswire.org/mailman/listinfo/jsword-devel
>
>**************************************************************************
>*  Aleksander Rozman - Andy  * Fandoms:  E2:EA, SAABer, Trekkie, Earthie *
>*     andy@kksonline.com     * Sentinel, BH 90210, True's Trooper,       *
>*    andy@atechnet.dhs.org   * Heller's Angel, Questie, Legacy, PO5,     *
>* Maribor, Slovenia (Europe) * Profiler, Buffy (Slayerete), Pretender    *
>*     ICQ-UIC: 4911125       *********************************************
>*     PGP key available      *    http://www.atechnet.dhs.org/~andy/     *
>**************************************************************************
>
>
>_______________________________________________
>jsword-devel mailing list
>jsword-devel@crosswire.org
>http://www.crosswire.org/mailman/listinfo/jsword-devel

_________________________________________________________________
Persistent heartburn? Check out Digestive Health & Wellness for information 
and advice. http://gerd.msn.com/default.asp