Skip to content

no need to explicitely list the snake case methods - #1918

Merged
karussell merged 5 commits into
masterfrom
snake_case
Feb 21, 2020
Merged

karussell merged 5 commits into
masterfrom
snake_case

Conversation

@karussell

@karussell karussell commented Feb 17, 2020 •

Copy link
Copy Markdown
Member

of GHRequest in GHRequestMixIn.

Unfortunately there seems to be no lowerCamelCase naming strategy. With such a strategy we could enable it globally and annotate only GraphHopperConfigMixIn (or should we create something like this?)

@karussell
karussell requested a review from easbar February 17, 2020 18:34
@karussell karussell mentioned this pull request Feb 17, 2020
58 of 71 tasks
@karussell karussell added this to the 1.0 milestone Feb 17, 2020

@easbar easbar left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

With such a strategy we could enable it globally and annotate only GraphHopperConfigMixIn (or should we create something like this?)

Hm not sure, I do not think we will get along without any mixins (for example because of @JsonAnySetter). Or maybe I did not understand what we could possibly enable globally?

return initObjectMapper(new ObjectMapper());
}

public static ObjectMapper initObjectMapperWithSnake(ObjectMapper objectMapper) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we ever want the mapper without the snake strategy? If not maybe we could simply put this in the existing initObjectMapper?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If we define the snake case globally, which I would really prefer, then we would need to rewrite all our config.yml (should we avoid this?). See 2f2567b

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wait what do you prefer? You want to use snake case everywhere? But isn't this what we do (the current config.yml uses snake case). And in 2f2567b you converted everything to camel case?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I would prefer a global snake case, yes. But this would break existing config.yml files as it includes e.g. applicationConnectors and it would be necessary to change this (and several other things) to snake_case.

I'm not sure if we should do this.

But isn't this what we do (the current config.yml uses snake case)

No, unfortunately not. See all the camelCase config properties from dropwizard. Also when switching to global snake case still the requestLog property made problems and wasn't available as snake_case, maybe something related to dropwizard/dropwizard#1558

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah right dropwizard uses camel case. But if thats the default why do we not just use camel case everywhere? Ok I would agree that snake case is prettier / more readable and more consistent with url parameters...

@karussell karussell Feb 19, 2020 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

we are breaking the configuration in many ways I think

Ah, indeed. Then I'll rework this PR to use the snake_case globally and document it in the changelog.

Also regarding the "dot": could we convert the current state:
datareader.file: somefile.pbf into an object structure like

datareader:
 file: somefile.pbf

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could we convert the current state: datareader.file: somefile.pbf into an object structure like

I think thats the point. When the property name is datareader.file (in the command line argument at least) dropwizard interprets this as the file property of the datareader object. The datareader object is missing in the configuration and thus the override fails. Otherwise yes we could convert it into an object structure, but this must be reflected on the java side (GraphHopperConfig.java). If we start grouping parameters together we should try to find out which ones are really related such that the sub-objects of GraphHopperConfig represent a meaningful decomposition and we can pass around these sub-objects to the different components (which ideally do not need to know anything about the other sub-objects). For example I did this with RoutingConfig in the GraphHopper class even though this is so far only done internally (not in config.yml yet).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But maybe this is something for GH 2.0 as its also related to how we will deal with the graphhopper folder cache/database in the future and what kind of refactorings will be done to the GraphHopper class, what should belong to the 'core' etc. :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok. So we keep the dots in the pararameters for 1.0 but move everything to snake_case?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sounds like a plan

@karussell

Copy link
Copy Markdown
Member Author

To make the transition a bit easier I have created https://github.com/karussell/snake_case which converts all the camelCase keys into snake_case (the only problem is that it removes the comments)

@karussell
karussell merged commit a369212 into master Feb 21, 2020
karussell added a commit that referenced this pull request Feb 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants