# Code Smell 92 - Isolated Subclasses Names

*If your classes are globals, use fully qualified names*

> TL;DR: Don't use abbreviations in subclasses

# Problems

- Readability

- Mistakes

# Solutions

1. Rename your classes to provide context

2. Use modules, namespaces or fully qualified names

# Sample Code

## Wrong

[Gist Url]: # (https://gist.github.com/mcsee/78ec88e709cd2a5efc4a0a09903c5a4e)
```java
abstract class PerserveranceDirection { 
}

class North extends PerserveranceDirection {}
class East extends PerserveranceDirection {}
class West extends PerserveranceDirection {}
class South extends PerserveranceDirection {}

//Subclasses have short names and meaningless outside the hierarchy
//If we reference East we might mistake it for the Cardinal Point
```

## Right

[Gist Url]: # (https://gist.github.com/mcsee/f46bfc303a23c3e6c2d31d7bb4168f28)
```java
abstract class PerserveranceDirection { 
}

class PerserveranceDirectionNorth extends PerserveranceDirection {}
class PerserveranceDirectionEast extends PerserveranceDirection {}
class PerserveranceDirectionWest extends PerserveranceDirection {}
class PerserveranceDirectionSouth extends PerserveranceDirection {}

//Subclasses have fully quallified names
```

# Detection

Automatic detection is not an easy task. We could enforce local naming policies for subclasses.

# Tags

- Naming

# Conclusion

Choose your names wisely.

If your language supports it, use modules, namespaces and local scopes.

# Relations

%[https://maximilianocontieri.com/code-smell-11-subclassification-for-code-reuse]

# More Info

- [What is in a name?](https://maximilianocontieri.com/what-exactly-is-a-name-part-i-the-quest)

- [MAPPER](https://maximilianocontieri.com/the-one-and-only-software-design-principle)

# Credits

Photo by <a href="https://unsplash.com/@edvardr">Edvard Alexander Rølvaag</a> on <a href="https://unsplash.com/s/photos/hierarchy">Unsplash</a>
  
* * *

> The programmer's primary weapon in the never-ending battle against slow system is to change the intramodular structure. Our first response should be to reorganize the modules' data structures.

_Frederick P. Brooks_
 
%[https://maximilianocontieri.com/software-engineering-great-quotes]

* * *

This article is part of the CodeSmell Series.

%[https://maximilianocontieri.com/how-to-find-the-stinky-parts-of-your-code]
