Dev Genius

Coding, Tutorials, News, UX, UI and much more related to development

Follow publication

Code Smell 42 — Warnings/Strict Mode Off

Maximiliano Contieri
Dev Genius
Published in
2 min readDec 4, 2020

Photo by Noah Dominic Silvio on Unsplash

Problems

  • Missed Errors
  • Ripple Effect
  • Fail Fast

Solutions

  1. Enable all warnings
  2. Enable preconditions and assertions in production.
  3. Fail fast
  4. Design by contract

Sample Code

Wrong

Right

Detection

Most languages have warning levels. We should turn most of them ON.

We should run linters to statically analyze our code for potential problems.

Tags

  • Fail Fast

Conclusion

If we ignore warnings and code moves on sooner or later it will fail.

If the software fails later it will be very difficult for us to find root cause.

Defect will likely be near first warning and far away from the crash.

If we follow the Broken Windows Theory, we should not tolerate any warnings, so a new issue will not pass unnoticed on a sea of tolerated warnings.

Relations

More info

One man’s crappy software is another man’s full time job.

Jessica Gaston

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Published in Dev Genius

Coding, Tutorials, News, UX, UI and much more related to development

Written by Maximiliano Contieri

I’m a senior software engineer specialized in declarative designs. S.O.L.I.D. and agile methodologies fan. Maximilianocontieri.com

No responses yet

Write a response