Dev Genius

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

Follow publication

Code Smell 66 — Shotgun Surgery

Maximiliano Contieri
Dev Genius
Published in
2 min readApr 5, 2021

Photo by William Isted on Unsplash

Problems

  • Bad Responsibilities Assignments
  • Code Duplication
  • Maintainability
  • Single Responsibility Violation.
  • Copy-pasted code.

Solutions

  1. Refactor

Sample Code

Wrong

Right

Detection

Some modern linters can detect repeated patterns (not just repeated code) and also while performing our code reviews we can easily detect this problem and ask for a refactor.

Tags

  • Code Duplication

Conclusion

Adding a new feature should be straightforward it our model maps 1:1 to real world and our responsibilities are in the correct places. We should be alert for small changes spanning in several classes.

More info

Duplication is the primary enemy of a well-designed system.

Robert Martin

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