Skip to content

refactor the EncodingManager to use the builder pattern - #1460

Closed
karussell wants to merge 17 commits into
intsref_refactoringfrom
refactor_enc_manager
Closed

karussell wants to merge 17 commits into
intsref_refactoringfrom
refactor_enc_manager

Conversation

@karussell

@karussell karussell commented Sep 20, 2018 •

Copy link
Copy Markdown
Member

This will make the EncodingManager more flexible, e.g. it will be possible later on to do something before adding a FlagEncoder like adding a "shared" EncodedValue (like road type to be available for multiple FlagEncoders)

Should we use the same Builder patter approach like we do in AlgorithmOptions:

EncodingManager.start().add(new CarFlagEncoder()).build();

or something different?

This PR is based on #1447

@karussell karussell added this to the 0.12 milestone Sep 20, 2018
@easbar

easbar commented Oct 17, 2018

Copy link
Copy Markdown
Member

I also like .hasEncoder() better than .supports(). Regarding the builder pattern I am not sure if I can follow your example. Do you want to just store the "shared" encoded value within the encoding manager or should it be added to every encoder that gets added during the building ? Do you have any specific alternative to the builder pattern in mind ?

@karussell

karussell commented Oct 17, 2018 •

Copy link
Copy Markdown
Member Author

Do you want to just store the "shared" encoded value within the encoding manager or should it be added to every encoder that gets added during the building ?

We already have EncodedValues in master but they live inside the FlagEncoders. With #1447 I extend the idea further and at some point in the future we could get rid of FlagEncoders and just have EncodedValues. So, yes. The shared EncodedValue is part of the EncodingManager and can be used from a Weighting but also within any FlagEncoder without duplicating it. E.g. in master the roundabout EncodedValue is duplicated for every FlagEncoder and the same ugliness would happen for a "surface" or "road class" EncodedValue but with a bigger bit range impact. So we need something like these shared EncodedValues to solve this duplication problem.

Do you have any specific alternative to the builder pattern in mind ?

... not really - I hoped you would have one :) !

@karussell

Copy link
Copy Markdown
Member Author

Please have a look into this discussion, where I link to this highly experimental branch, where I develop the idea further, introduce a yml/json format to define a different profile per request.

@easbar

easbar commented Oct 17, 2018

Copy link
Copy Markdown
Member

Thanks for the pointers, I will have to take a closer look at EncodedValues. I think using the builder pattern like you did seems to be a reasonable way to share the encoded values between different encoders that get added to the manager.

This was referenced Jan 12, 2019
@karussell

Copy link
Copy Markdown
Member Author

Somehow I cannot change the target branch, so created this new at #1546

@karussell karussell closed this Feb 19, 2019
@karussell karussell removed this from the 0.12 milestone Feb 19, 2019
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