Congratz! These are really helpful tips. I hope you don't mind me sharing a few more :)
The second tip features an example that realistically would be better solved by introducing a Value Object, but it is still a good example on how to clean up your code by replacing simple if/else with ternary operator.
To learn more about Value Objects, you can check out this article.
For the ninth tip, personally I would also drop the usage of [-1] syntax.
Imagine you're code pairing and you're telling your partner that they should pick the last element.
You see? It's easier to read through a code that is written kind of the way we are used to speak. So elements.last reads much better than elements[-1].
Hi Marcelo, thank you so much for your suggestions!
I didn't know about Value Objects. This article is really helpful.
Also, I was actually thinking about dropping [-1] syntax from the ninth item. I decided to keep it as another option but your explanation really makes sense. I might be going to update my article.
Thank you, again!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Congratz! These are really helpful tips. I hope you don't mind me sharing a few more :)
The second tip features an example that realistically would be better solved by introducing a Value Object, but it is still a good example on how to clean up your code by replacing simple if/else with ternary operator.
To learn more about Value Objects, you can check out this article.
For the ninth tip, personally I would also drop the usage of
[-1]
syntax.Imagine you're code pairing and you're telling your partner that they should pick the last element.
You see? It's easier to read through a code that is written kind of the way we are used to speak. So
elements.last
reads much better thanelements[-1]
.Hi Marcelo, thank you so much for your suggestions!
I didn't know about Value Objects. This article is really helpful.
Also, I was actually thinking about dropping [-1] syntax from the ninth item. I decided to keep it as another option but your explanation really makes sense. I might be going to update my article.
Thank you, again!