DEV Community

Discussion on: How to Write a Good Piece of Code

 
taillogs profile image
Ryland G

Your points are valid, and I think in the end, we agree.

Great start

I speak about roughly a million LoC codebases in enterprise environments.

You won't throw away the consistency/maintainability of your codebase just to teach people why they should not mix tabs with spaces.

Learn the fundamentals without a linter, true, but don't learn it by introducing inconsistent code to master.

I know it's unrealistic but I wish most entry devs already had these skills, education system is really failing in that sense. This is also part of the reason enterprise gets a bad rap, they optimize for developer output and not developer development.

On the other hand, you might not want to reformat automatically your code on each commit, but you can just deal with the error messages given right before the compilation by the CI pipeline. But, I don't think that's efficient.

It's funny. When I had to learn JavaScript for my company, I did so with a linter but not integrated into vim. So my development phase would look like,

  1. Write tests
  2. Write code
  3. See tons of lint errors
  4. Fix lint errors
  5. Repeat

Because linting at the end was so much less convenient, my brain picked up on the rules really quickly. After only a week or so, my "natural linting" was such that I almost never had linter errors. To this day, I don't use an integrated linter in vim because my accuracy is so high. It's like I have a built-in linter.

But obviously all Jenkins builds etc should have a linting precursor.

Read articles, books, participate at coding dojos, build your own tools and side projects and actually read the coding guidelines you have to comply with. Try to understand it. In most cases, the coding guidelines/standard don't just give you rules, but the _why_s behind as well. If not, ask questions.

Couldn't agree more. We really do agree in the end (literally).

Thanks for the great discussion. I hope others read it too because I really think it adds to the value of the post.