DEV Community

Cover image for Code Smell 44 - Magic Corrections
Maxi Contieri
Maxi Contieri

Posted on • Updated on • Originally published at maximilianocontieri.com

Code Smell 44 - Magic Corrections

Compilers are smarter than us. On a Friday night production deploy they betray us.

Problems

  • Fail Fast

  • Declarativeness

  • Ambiguity

Solutions

  1. Fail Fast

  2. Do not trust magic coercion.

  3. Be Explicit

Examples

  • Type Casting

Sample Code

Wrong

Right

Detection

Many of this vicious are encouraged by languages themselves.

We should be very declarative and explicit and don't abuse language accidental magic solutions.

Tags

  • Declarative

  • Smart

Conclusion

Programmers pretend to be smart by exploiting language features.

They feel they belong to community standards that enforce bad behaviors like a sect.

Relations

More Info

Credits

Photo by Senor Sosa on Unsplash


Hackers are arrogant geek romantics. They lack the attentive spirit of inquiry.

Bruce Sterling

Top comments (0)