Dev Genius

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

Follow publication

Code Smell 85 — And Functions

Maximiliano Contieri
Dev Genius
Published in
1 min readAug 21, 2021

Photo by Paul on Unsplash

TL;DR: Unless you need atomicity, do not perform more than one task.

Problems

  • Coupling
  • Single Responsibility Principle violation
  • Readability
  • Low Cohesion
  • Testability

Solutions

  1. Break the function

Sample Code

Wrong

Right

Detection

Functions including “and” are candidates. However, we need to check them carefully since there might be false positives.

Tags

  • Readability
  • Naming

Conclusion

We should avoid doing more than needed, and our functions should be both minimal and atomic.

More Info

Credits

This smell was inspired by

If it takes more than a sentence to explain what you are doing, it’s almost always a sign that what you are doing is too complicated.

Sam Altman

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