Dev Genius

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

Follow publication

Code Smell 59 — Basic / Do Functions

Maximiliano Contieri
Dev Genius
Published in
2 min readJan 27, 2021

--

Photo by Roger Bradshaw on Unsplash

Problems

  • Readability
  • Bad Naming
  • Low Cohesion
  • Single Responsibility Principle

Solutions

  1. Use good object wrappers
  2. Use dynamic decorators

Sample Code

Wrong

Right

Detection

We can instruct our static linters to find wrapping methods if they follow conventions like doXXX(), basicXX() etc.

Tags

  • Declarativeness

Conclusion

We came across this kind of methods some time in our developer life, We smelled something was not OK with them. Now is the time to change them!

More info

The primary disadvantage of Wrap Method is that it can lead to poor names. In the previous example, we renamed the pay method dispatchPay() just because we needed a different name for code in the original method.

Michael Feathers

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