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
- 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
Right
class Employee
def initialize(@first_name : String, @last_name : String, @birthdate : Time)
end
end
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.
About the author
I’m a senior software engineer loving clean code, and declarative designs. S.O.L.I.D. and agile methodologies fan.
Comments
Join the discussionNice one. I feel it will also apply to instance variables,
class Employee:
def __init__(self):
self.employee_first_name = ''
to this,
class Employee:
def __init__(self):
self.first_name = ''
Code Smells
In this series, we will see several symptoms and situations that make us doubt the quality of our developments. We will present possible solutions. Most are just clues. They are no hard rules.





