DEV Community

loading...

Discussion on: Which contentious opinions in programming actually matter?

Collapse
sreisner profile image
Shawn Reisner

This is a great question. I think there's some contention between people who are very pedantic about code style consistency across a project and those who don't think it's important. I'm in the "very pedantic" camp because having a consistent style is the easiest way to remove friction in the readability of your code. It removes one additional barrier to understanding and it's something I think is very important.

Collapse
trg profile image
Tom G

Using editorconfig or something similar to assist editors in automatically maintaining the style of the project is nice.

Collapse
jillesvangurp profile image
Jilles van Gurp

Instead of being pedantic about style, which is very exhausting, I find it much more constructive to do automatic formatting at build time. I've set this up on a bunch of projects. This removes this as a topic of discussion and frees everybody up to disagree about more interesting things ;-)

Collapse
sreisner profile image
Shawn Reisner

I agree 100%. I do automatic formatting at build time because I'm so pedantic about style.

Collapse
charliedevelops profile image
charliedeveloper Author

thanks for the reply!
I definitely agree being consistent is important for readability of your code.
One thing that I would be interested to hear your opinion on with regards to this topic, is how would you approach consistency of code style when updating legacy codebases?

eg: have historically used inline css styles for particular attributes however this is now causing precedence issues with external stylesheets for other newer parts of the system? Would you lean towards engineering it to work with the consistent old style or encourage team to set up a new code style and edit all the old stuff?

apologies if the example isn't the clearest!

Collapse
sreisner profile image
Shawn Reisner

As always, it depends. Without more context, my gut reaction is that if your old inline styles are causing precedence issues and making it difficult to move forward with your project because you're always having to go back and deal with these frustrating issues, I'd say it's probably time to go in and refactor those inline styles. Those constant nagging issues don't just slow you down, they make developers unhappy. And unhappy developers quit, which is another major cost. Just something to think about!

Thread Thread
charliedevelops profile image
charliedeveloper Author

good answer! i suppose thats a good rule for all of development - follow a particular way of thinking until there is overwhelming evidence to do something else!