Timeline for Find the cheapest shipping option based on item weight
Current License: CC BY-SA 4.0
12 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 3, 2019 at 8:39 | comment | added | stefan | I disagree about the "further refactoring" sections. IMHO they are violating some principles of the "Zen of Python", especially "simple is better than complex" and "readability counts". | |
May 3, 2019 at 8:19 | comment | added | Maarten Fabré |
@lucasgcb Personally, the further refactoring it's something I would use, especially if you want to start later with configuration files instead of hard-coded parameters.. I understand that it can be daunting for newcomers to python, so I totally understand when they don't use it, but I do want to make them aware that this is one of the possibilities. The if-elif chain has it advantages in readability, the refactored, generalized method has it's advantages in adaptability and re-usability. The programmer has to choose in his case which is the more appropriate approach.
|
|
May 3, 2019 at 8:19 | comment | added | JollyJoker | @jpmc26 How about a list of objects that have max_weight and cost properties? | |
May 3, 2019 at 8:05 | comment | added | lucasgcb | While this reduces LOC it's not very readable to anyone who isn't all-in on Python in my opinion; like jpmc26 noted, just because you can doesn't mean you should. | |
May 3, 2019 at 7:15 | history | edited | Maarten Fabré | CC BY-SA 4.0 |
added 29 characters in body
|
May 2, 2019 at 22:06 | comment | added | jpmc26 |
I would not use a dict to represent a range relationship. This is very unintuitive.
|
|
May 2, 2019 at 14:31 | comment | added | Maarten Fabré | You are correct. First I used a sorted list, then figured a dict would be a better days structure and forgot to change the text. I will correct this when I have the time | |
May 2, 2019 at 14:20 | comment | added | Graipher |
"thresholds is a sorted list with the factor for the weights." No it's not. It is a dictionary with the thresholds and factors which is sorted in Python 3.7+ and in arbitrary order before that. sorted(thresholds.items()) however is a sorted iterable in all Python versions, but it also contains both the threshold and the factor.
|
|
May 2, 2019 at 12:13 | vote | accept | Stephen | ||
May 3, 2019 at 9:39 | |||||
May 2, 2019 at 10:59 | history | edited | Maarten Fabré | CC BY-SA 4.0 |
added 178 characters in body
|
May 2, 2019 at 10:56 | comment | added | Stephen | Thanks for taking your time to give me this very in-depth response I really appreciate it. Although I don't understand everything going on here (as I'm still new to Python) I can certainly say I've learnt a thing or two from it! | |
May 2, 2019 at 10:48 | history | answered | Maarten Fabré | CC BY-SA 4.0 |