DEV Community

Cover image for Code Smell 188 - Redundant Parameter Names
Maxi Contieri
Maxi Contieri

Posted on • Originally published at maximilianocontieri.com

3

Code Smell 188 - Redundant Parameter Names

Use contextual and local names

TL;DR: Don't repeat your parameters' names. Names should be contextual.

Problems

  • Duplication

  • Readability

Solutions

  1. Remove the repeated part from the name

Context

When using names, we often miss that words are contextual and need to be read as a whole sentence.

Sample Code

Wrong

class Employee
  def initialize(@employee_first_name : String, @employee_last_name : String, @employee_birthdate : Time)
  end
end

Enter fullscreen mode Exit fullscreen mode

Right

class Employee
  def initialize(@first_name : String, @last_name : String, @birthdate : Time)
  end
end
Enter fullscreen mode Exit fullscreen mode

Detection

[X] Semi-Automatic

We can check our parameter names and try to find duplication.

Tags

  • Naming

Conclusion

Use short and contextual names for your parameters.

Relations

Disclaimer

Code Smells are just my opinion.

Credits

Photo by Wolfgang Hasselmann on Unsplash


As a rule, software systems do not work well until they have been used, and have failed repeatedly, in real applications.

David Parnas


This article is part of the CodeSmell Series.

Sentry image

Make it make sense

Make sense of fixing your code with straight-forward application monitoring.

Start debugging →

Top comments (0)

AWS Q Developer image

Build your favorite retro game with Amazon Q Developer CLI in the Challenge & win a T-shirt!

Feeling nostalgic? Build Games Challenge is your chance to recreate your favorite retro arcade style game using Amazon Q Developer’s agentic coding experience in the command line interface, Q Developer CLI.

Participate Now

👋 Kindness is contagious

Discover fresh viewpoints in this insightful post, supported by our vibrant DEV Community. Every developer’s experience matters—add your thoughts and help us grow together.

A simple “thank you” can uplift the author and spark new discussions—leave yours below!

On DEV, knowledge-sharing connects us and drives innovation. Found this useful? A quick note of appreciation makes a real impact.

Okay