-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StackWizardSettings breaks java.util.Map contract #73
Comments
Hello! I wasn't involved in the project when #46 was opened (or closed), so I have no response to that, but please let me take a look at this and see what I can do about it. Thanks. |
maybe it would be better if it just extends HashMap, that would probably fix this and enable us to delete a bunch of code |
ehh on second though, i'm not sure that suggestion would work. |
I'm going to dig into this this coming week. @spyhunter99 if you have any ideas, I want to hear them and could you please do me a favor... email me at steve@lobosstudios.com from an email address you would like to use to communicate about this project. You've emailed me in the past but I have no idea if I still have those emails. And we may need to discuss things that don't make sense to discuss here :) thanks |
So, @spyhunter99 opened #46 and then immediately closed it, but his comment about the |
@stevesobol, as I've said, I think that
This doesn't break binary compatibility, but it does break the behavior (again, |
Ok. Let me get to work on this - thanks for your feedback |
so... I have Wizard Settings not implementing |
|
|
@nigredo-tori I haven't opened a pull request yet. I also haven't tested the changes yet. But I'd like you to look at them. [branch deleted] |
@stevesobol, off the top of my head:
Also, I can think of a few convenience |
@nigredo-tori I am still here FYI :) trying to find time to work on this, am working on it today and I'm thinking we get all of these things done, including the convenience methods, and since we have major changes, the next release will be 2.0.0 instead of 1.0.10 as I'd planned. There are still things I need to get done (much better docs, a real website, unit testing). But they can wait imho. |
Haven't forgotten about this. Things have been crazy and I've had to focus on getting new work. |
I'm starting clean. I'm not sure exactly where I was with the changes. The branch I linked to earlier is gone, so I'm going to remove the link to it. |
I'm going to have to update WizardSettings too, as StackWizardSettings extends that class and it extends |
I think I'm going to have to grab the source code for Thank $DEITY for OpenJDK. |
@nigredo-tori hm. OpenJDK is GPL-licensed which means that we'd also need cjwizard to be GPL licensed if I was to snarf the source code for |
Please don't do that. Reimplementing library classes is generally not a good idea. In fact, this very issue is about It should be easier and cleaner to solve this with aggregation. For example: public interface WizardSettings {
void rollBack();
void newPage(String id);
void commit();
/** Get a {@code Map} with settings for the current page.
* Mutating the resulting map will mutate the settings.
*/
Map<String, Object> getCurrentPageSettings();
/** Build a {@code Map} with settings for all the pages.
* Mutating the resulting map will not mutate the settings.
*/
Map<String, Object> buildFullSettings();
// We can provide convenience wrappers for methods we use the most.
/** Put a key-value pair into the current page settings.
* @return previous value for this key on the current page, or {@code null}.
*/
default Object put(String key, Object value) {
return getCurrentPageSettings().put(key, value);
}
/** @return the value for the key in full settings, or {@code null}. */
default Object get(String key) {
return buildFullSettings().get(key);
}
} I don't like |
use a wrapper pattern instead of copy and paste
…On Wed, Sep 11, 2019 at 11:02 PM nigredo-tori ***@***.***> wrote:
@stevesobol <https://github.com/stevesobol>,
I think I'm going to have to grab the source code for Map and basically
create a duplicate class, minus the stuff we do not need. Too many methods
to rewrite otherwise.
Please don't do that. Reimplementing library classes is generally not a
good idea. In fact, this very issue is about StackWizardSettings
incorrectly implementing Map. 😄
It should be easier and cleaner to solve this with aggregation. For
example:
public interface WizardSettings {
void rollBack();
void newPage(String id);
void commit();
/** Get a ***@***.*** Map} with settings for the current page.
* Mutating the resulting map will mutate the settings.
*/
Map<String, Object> getCurrentPageSettings();
/** Build a ***@***.*** Map} with settings for all the pages.
* Mutating the resulting map will not mutate the settings.
*/
Map<String, Object> buildFullSettings();
// We can provide convenience wrappers for methods we use the most.
/** Put a key-value pair into the current page settings.
* @return previous value for this key on the current page, or ***@***.*** null}.
*/
default Object put(String key, Object value) {
return getCurrentPageSettings().put(key, value);
}
/** @return the value for the key in full settings, or ***@***.*** null}. */
default Object get(String key) {
buildFullSettings().get(key);
}
}
I don't like getCurrentPageSettings returning a mutable backing map -
this constrains the implementation too much. However, since this whole
interface is written in a mutable style, this should do for now.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#73?email_source=notifications&email_token=AAPCIGIGUQK5CJUQ7HUUOFLQJGWNJA5CNFSM4FVODXP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6QP57A#issuecomment-530644732>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAPCIGKIWZ533SPY6CB3MPTQJGWNJANCNFSM4FVODXPQ>
.
|
does this help? #82 |
I'm sure it will. I'll check it out asap. I am so sorry, guys. I'm being stupid about this. Lots going on over here, but that's no excuse. |
#73 reworks the map interface issue
.entrySet()
and.values()
, making the whole thing unsafe to use with the code that expects a properMap
(e.g. to save the resulting settings into a file). Is there a reason why it's implemented this way? There's an issue (WizardSettings.entrySet throws unsupported operating error #46) about it, but I don't quite get why it was closed. Unless, indeed,StackWizardSettings
should only be used for controlling the wizard flow, and not for accumulating the resulting settings. Which doesn't seem to be the case, since the data from the named components winds up inside it..keySet()
is not backed by theStackWizardSettings
object, which contradicts theMap
documentation:remove
method), they still break the contract!It seems to me that the
WizardSettings
interface shouldn't extendsMap
at all, and should instead provide a way to get aMap
that would be either a snapshot of, or backed by, the current stack item, as well as a way to get an effectiveMap
snapshot for the whole stack.The text was updated successfully, but these errors were encountered: