Simplifying the code
abhishek-jain-1999 opened this issue ยท 9 comments
Prerequisites
- I am running the latest version
- I checked the documentation and found no answer
- I checked to make sure that this issue has not already been filed
Context
- Package Version: Latest merge
- Operating System: Window 10
Current Behavior & Expected Behavior
Example : In fhir_helper.py (line 564)
temp = j['valueCodeableConcept']['coding'][0]["system"]
od_componentvalue_codeable_concept["system"] = temp
it can be converted into this
od_componentvalue_codeable_concept["system"] = j['valueCodeableConcept']['coding'][0]["system"]
and like these code of lines in the project
@rhdolin @srgothi92 please tell me if this cannot be considered as an issue or if there something relate to this code that I am not aware of
@abhishek-jain-1999, the code was od_componentvalue_codeable_concept["system"] = j['valueCodeableConcept']['coding'][0]["system"]
before and I changed it to
temp = j['valueCodeableConcept']['coding'][0]["system"]
od_componentvalue_codeable_concept["system"] = temp
because according to PEP 8 we can only have 79 characters in a line.
@Rohan-cod okay now I understand why there were such changes but don't you think it is useless to have a temp variable made in memory not only just to give it away it next line but also to keep in memory until it is dumped
in short double memory usage will be there and unnecessary time will be used as it is been done at multiple places
and also as code reader it is confusing to see a variable been made and not been use later
like for example
if 'code' in j['valueCodeableConcept']['coding'][0]\
.keys(
):
t = j['valueCodeableConcept']['coding'][0]["code"]
od_componentvalue_codeable_concept["code"] = t
this looks much simpler to understand
if 'code' in j['valueCodeableConcept']['coding'][0].keys():
od_componentvalue_codeable_concept["code"] = j['valueCodeableConcept']['coding'][0]["code"]
You are absolutely correct @abhishek-jain-1999. If you have any other way to conform to the rule of having no more than 79 characters in a single line you can do that, but using od_componentvalue_codeable_concept["code"] = j['valueCodeableConcept']['coding'][0]["code"]
will cause the checks to fail.
@Rohan-cod Thanks for your response . Let me see if I am able to find another way to handle this issue
No Problem @abhishek-jain-1999 ๐. All the best ๐
@abhishek-jain-1999, I figured out a way to do this. I missed it while I was changing the code ๐
.
Changing the code from ๐
if 'code' in j['valueCodeableConcept']['coding'][0]\
.keys(
):
t = j['valueCodeableConcept']['coding'][0]["code"]
od_componentvalue_codeable_concept["code"] = t
to ๐
if 'code' in j['valueCodeableConcept']['coding'][0]\
.keys(
):
od_componentvalue_codeable_concept["code"] =\
j['valueCodeableConcept']['coding'][0]["code"]
and doing the same at other locations will help you remove most of the temporary variables.
Just an option. Completely up to you, if you want you can use my approach.
Nice work everyone, I really like the conversation that is happening in each issues and PR.
Contributors Cheers ๐ท
Nice work everyone, I really like the conversation that is happening in each issues and PR.
Contributors Cheers ๐ท
Cheers @srgothi92 ๐