Structural Pattern Applied #462
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There were functions that does data lookup for a key. Country code lookup and Population lookup are example of these. However it would be useful to have a centralized registry where you can perform all these lookup based on the key. Even though the type of data thats being looked up different, the manner of accessing the lookup the data would be the same. That is you'd provide a key and there would be a default value if the data is not present related to the key. The logic for Country code lookup and Population lookup yields different algorithms and the returned data is also different. Therefore I designed a lookup class that hides such details and exposes the functionality via a get method where u pass a key and if needed a default value. Then both the Country code lookup and Population lookup functions are converted in to sub classes of the lookup class where the get method implements the logic. An instance of these classes is registered in the lookup registry located at utils.lookup.py module. Now whenever we want to lookup data we just call the utils.lookup.get(<lookup_type>, [,<default_value>]) where lookup_type is in this PR is either "country_code" or "country_population".