It is nice to see a class implementing Interfaces. It is nicer to understand what it does
TL;DR: Name your classes after real-world concepts.
- Find the correct name using the MAPPER
Some languages bring idioms and common usages against good model naming.
We should pick our names carefully.
public interface Address extends ChangeAware, Serializable {
String getStreet();
}
// Wrong Name - There is no concept 'AddressImpl' in the real world
public class AddressImpl implements Address {
private String street;
private String houseNumber;
private City city;
// ..
}
// Simple
public class Address {
private String street;
private String houseNumber;
private City city;
// ..
}
// OR
// Both are real-world names
public class Address implements ContactLocation {
private String street;
private String houseNumber;
private City city;
// ..
}
[X] Automatic
Since this is a naming smell.
We can search using regular expressions and rename these concepts.
- Naming
We should pick class names according to essential bijection and not follow accidental implementation.
Do not call I to your interfaces.
Code Smell 65 - Variables Named after Types
Code Smell 38 - Abstract Names
What exactly is a name - Part II Rehab
Photo by Paula Hayes on Unsplash
Encoded names are seldom pronounceable and are easy to miss-type.
Robert C. Martin
Software Engineering Great Quotes
This article is part of the CodeSmell Series.