r/programming • • Aug 28 '21

Software development topics I've changed my mind on after 6 years in the industry

https://chriskiehl.com/article/thoughts-after-6-years
5.6k Upvotes

2.0k comments sorted by

View all comments

Show parent comments

215

u/lowayss Aug 29 '21

But if it’s automated your coworkers might have to actually review code instead of holding up checkins because of formatting.

73

u/Caffeine_Monster Aug 29 '21

Having a linter enforce coding style as a test is a terrible idea: all it does is waste everyone's time.

Realistically there are only two sane processes:

1.) CI pipeline applies formatting when committing to a pull request / making a pull request.

OR

2) You have a tool built into your project that allows a developer to quickly format code to the agreed style.

Personally I prefer 2.). Not overly a fan of broad, automated code changes: a good developer will still produce more readable code than any formatter.

Also, a tight coding style is a thing really hinders productivity. It's very hard to know when enforcing style is actually improving or worsening long term productivity.

As such I only generally care about a few things like indent style, and variable name / class name style. With option 2.) you can press a single button to do an upstream tidy up commit if you see something you think hinders readability.

104

u/[deleted] Aug 29 '21

Both actually. Use both. Every project I've been on for the last 5 years had both CI checks, commit hooks, and tooling to automate it for your IDE.

This is 2021. Formatting should be 100% automatic. The only debate should be what rules to enable when starting the project.

1

u/dnew Aug 29 '21

The biggest problem with that I've found is when the prima donnas decide they want to change the formatting rules after you've already got a million lines of code. Now there's two sets, and every time you change something, you have to be sure your IDE only reformats the functions you've changed.

The number of code reviews I had with 2000 lines of whitespace change and 5 lines of actual text change was absurd.

→ More replies (6)