Hi Thomas, I loved your small example. This is exactly why I was fighting for in my ex-team, "yeah, but I won't create a function for only one line of code"... Stubborn junior devs, they've made me loss a few hair ahah.
I guess your former colleagues were still OK with adding comments in case of especially obscure logic?
So it's either this:
// Retired product SKUs end with X
if (sku.endsWith("X"))
or that
if (isRetiredProductSKU(sku))
The second version is actually more maintainable. The rules for detecting a retired product SKU might change over time. In case of the first version with the comment it would be necessary to update both the code and the comment, and usually the latter one is forgotten.
Anyway, for people who are really allergic to writing extra functions, here's another variant that is also more readable:
const isRetiredProductSku = sku.endsWith("X");
if (isRetiredProductSku) {
...
}
I think sometimes the best you can do in a team like that is to lead by example in your own contributions, and eventually they start appreciating the readability of the code you write and adopt your style 🤷♂️
I totally agree with you. Yeah, I've tried to lead by example, but that didn't work either. But thanks to that my manager moved me in another team, much much better! That was such an experience, professionally: working with really bad code, and personally: mental health ahah.
I think they didn't listen because I'm younger, by ego I suppose, I don't really know but that's bad for them.
We have to let your ego aside and listen to people to progress :)
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.
Hi Thomas, I loved your small example. This is exactly why I was fighting for in my ex-team, "yeah, but I won't create a function for only one line of code"... Stubborn junior devs, they've made me loss a few hair ahah.
Ah how rude of them! 😆
I guess your former colleagues were still OK with adding comments in case of especially obscure logic?
So it's either this:
or that
The second version is actually more maintainable. The rules for detecting a retired product SKU might change over time. In case of the first version with the comment it would be necessary to update both the code and the comment, and usually the latter one is forgotten.
Anyway, for people who are really allergic to writing extra functions, here's another variant that is also more readable:
I think sometimes the best you can do in a team like that is to lead by example in your own contributions, and eventually they start appreciating the readability of the code you write and adopt your style 🤷♂️
I totally agree with you. Yeah, I've tried to lead by example, but that didn't work either. But thanks to that my manager moved me in another team, much much better! That was such an experience, professionally: working with really bad code, and personally: mental health ahah.
I think they didn't listen because I'm younger, by ego I suppose, I don't really know but that's bad for them.
We have to let your ego aside and listen to people to progress :)