Dev Genius

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

Follow publication

Code Smell 93 — Send me Anything

Maximiliano Contieri
Dev Genius
Published in
2 min readOct 13, 2021

Photo by Hennie Stander on Unsplash

TL;DR: Create a clear contract. Expect just one protocol.

Problems

Solutions

1. Take just one “kind” of input

2. Arguments should adhere to a single protocol.

Sample Code

Wrong

Right

Detection

We can detect this kind of methods when they do different things, asking for the argument kind.

Tags

  • If Polluter

Conclusion

Magic castings and flexibility have a price. They put the rubbish under the rug and violate fail fast principle.

Relations

Referential transparency is a very desirable property: it implies that functions consistently yield the same results given the same input, irrespective of where and when they are invoked.

Edward Garson

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

Responses (2)

Write a response

Error prune

Did you mean Error Prone?

--

PHP only recently included optional parameter typing but what happens with weakly typed languages like JS, what the solution would be?

--