pivot-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Brown <gkbr...@mac.com>
Subject Re: Preferences class
Date Fri, 10 Apr 2009 15:12:30 GMT
>On Preferences:
>- in the new skeleton (form Subversion), the class now extends Task,
>while the Image (taken as example by me) extends IOTask ... what is
>better ?

Since these tasks will be reading from/writing to the file system, IOTask is probably slightly
better. However, the only thing IOTask really offers beyond Task is stream monitoring, which
you're not likely to need to use here. So either one is fine.

>- as by Web Start Persistence constraint, it's not possible to
>save/load data using a real URL (unless it's derived from the Codebase
>URL form where the application has been downloaded), so what do you
>think that instead of have a parameter URL url in constructors, if we
>use there a String name ? This could help to remove and simplify some
>code (like fixUrl, static utility methods, and other tricks) ...

I have to believe that this is a common problem when writing Web Start apps. See if you can
find some documentation on how other developers have handled this.

>- verify if implement other XxxxTask methods for remaining "user"
>public methods (dump, exist, delete, list), and then, if remove old
>versions of them (standard methods inside Preferences), or at least if
>keep only dump() ...

I don't think we need these methods, since you can get the same functionality from JSONSerializer.

>- listeners, must they be added to standard methods (get/put/remove),
>or are they already ok as in Greg stub ?

I intentionally removed the listeners, for the reasons outlined in the commit: there isn't
a strong use case for events in this class, and it would cause confusion, because directly
modifying nested objects won't fire events. For example, consider:

{a: {b:"c"}}

If I call prefs.put("a.b", "d"), we can fire an event, because the Preferences class is handling
the put(). But if I call:

Map<String, Object> a = (Map<String, Object>)prefs.get("a");
a.put("b", "d");

we can't, since "a" has no way to notify the preferences object that its contents changed.

>- synchronized methods, check if/where needed ... later
>- testing: I have to write a dedicated testCase2 method for the
>LoadTask/SaveTask, etc ...

You shouldn't need to synchronize anything here - that is handled for you by the Task class.

>Sorry for all these questions, with this rewrite I'd like to align as
>much as possible Preferences with Pivot way ...

I've tried to make it as simple as possible.  :-)  Just plug your serialization code in where
you see TODO in the comments. You shouldn't need to do much beyond that, but let me know if
you have any other questions.





Mime
View raw message