Skip to content
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

Less global and mutable state #285

Merged
merged 1 commit into from
Jan 6, 2021
Merged

Conversation

ppalaga
Copy link
Contributor

@ppalaga ppalaga commented Dec 22, 2020

@gnodet this should be a pure refactoring with no changes of behavior. The main intention is to make the code easier to read and easier to reason about.

@gnodet
Copy link
Contributor

gnodet commented Jan 4, 2021

I'm still hesitant to deviate the DaemonMavenCli too much from the MavenCli...

@ppalaga
Copy link
Contributor Author

ppalaga commented Jan 4, 2021

I'm still hesitant to deviate the DaemonMavenCli too much from the MavenCli...

I agree that keeping DaemonMavenCli as close as possible to MavenCli would simplify donating the Daemon to ASF. OTOH, DaemonMavenCli is the main part of Maven that we customize. Thus, when we start backporting our changes to Maven, MavenCli will have to change anyway. In that situation, I believe, it will be better to approch MavenCli with a clean design in mind. So if this PR brings a cleaner design to DaemonMavenCli any divergence from MavenCli should not be considered an obstacle. WDYT?

@ppalaga ppalaga force-pushed the 201222-refactor branch 3 times, most recently from e17fd4f to 407b615 Compare January 5, 2021 20:59
@ppalaga
Copy link
Contributor Author

ppalaga commented Jan 5, 2021

I have removed the second commit for now and I have simplified the first one as much as possible. Could you please re-review?

private static void configure(
CliRequest cliRequest,
EventSpyDispatcher eventSpyDispatcher,
Map<String, ConfigurationProcessor> configurationProcessors)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above...
Those methods are private and need to be given fields, so it's better to make them non static imho.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

configure is called twice with different params, so it is IMO safer not to allow reading the instance fields.

Slf4jLoggerManager plexusLoggerManager,
Logger slf4jLogger,
ILoggerFactory slf4jLoggerFactory,
Function<CliRequest, TransferListener> createTransferListener) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the benefit of using a static method and passing all parameters ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually now, that those fields are final, you are right, the method could be non-static without any danger that we inadvertently change the state. Let me change it.

@ppalaga
Copy link
Contributor Author

ppalaga commented Jan 6, 2021

2fc3cec: improved what I was able to. Is this good to merge now?

@gnodet
Copy link
Contributor

gnodet commented Jan 6, 2021

2fc3cec: improved what I was able to. Is this good to merge now?

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants