Code Smell 130 — AddressImpl

TL;DR: Name your classes after real-world concepts.

Problems

Solutions

  1. Find the correct name using the MAPPER

Context

Some languages bring idioms and common usages against good model naming.

We should pick our names carefully.

Sample Code

Wrong

public interface Address extends ChangeAware, Serializable {    /**
* Gets the street name.
*
* @return the street name
*/
String getStreet();
//...
}
//Wrong Name - There is no concept 'AddressImpl' in real world
public class AddressImpl implements Address {
private String street;
private String houseNumber;
private City city;
//..
}

Right

//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;
//..
}

Detection

[X] Automatic

Since this is a naming smell.

We can search using regular expressions and rename these concepts.

Tags

  • Naming

Conclusion

We should pick class names according to essential bijection and not follow accidental implementation.

Do not call I to your interfaces.

Relations

More Info

Credits

Photo by Paula Hayes on Unsplash

Encoded names are seldom pronounceable and are easy to miss-type.

Robert C. Martin

--

--

--

I’m a senior software engineer specialized in declarative designs. S.O.L.I.D. and agile methodologies fan. Maximilianocontieri.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to move an EC2 Instance to another AWS Region?

How to fix support for password authentication was removed on GitHub

Exploring Headless CMS

Feature Highlights: Maestro Cluster

Chirp + TOTP (Generation and Transmission)

Tutorial Fuzzy Logic Mamdani for Arduino

Tutorial Fuzzy Logic Mamdani for Arduino

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Maximiliano Contieri

Maximiliano Contieri

I’m a senior software engineer specialized in declarative designs. S.O.L.I.D. and agile methodologies fan. Maximilianocontieri.com

More from Medium

Why Fail-fast Offensive Programming is better?

Code Smell 129 — Structural Optimizations

An introductory guide to functional programming concepts

Introduction to Functional Concepts

Ideas on Performing High Value Code Reviews