Skip to main content

Command Palette

Search for a command to run...

Kotlin Code Smell 28 - Abstract Names

Unleashing the Magic of Meaningful Naming

Updated
1 min read
Kotlin Code Smell 28 - Abstract Names

Problem

  • Implemental Naming
  • Meaningless names
  • Broken MAPPER and Bijection to real-world entities.

Solution

  1. Choose meaningful names.
  2. Find metaphors.
  3. Avoid words like abstract, base, generic, helper, data, info, etc.
  4. Use rules for naming.

Sample Code

Wrong

class Repository {
    // ...
}

class MeetingCollection {
    // ...
}

class AccountsComposite {
    // ...
}

class NoteArray {
    // ...
}

class LogCollector {
    // ...
}

abstract class SearcherBase {
    // ...
}

abstract class AbstractTransportation {
    // ...
}

Right

class Schedule {
    // ...
}

class Portfolio {
    // ...
}

class NoteBook {
    // ...
}

class Journal {
    // ...
}

class Vehicle {
    // ...
}

Conclusion

Finding names is the last thing we should do in our designs. Unless we have a clear business understanding, good names emerge at the end after defining behavior and protocol boundaries.

Credits

Kotlin Code Smells

Part 9 of 36

In this series, we will see several symptoms and situations that make us doubt the quality of our development. We will present possible solutions. Most are just clues. They are no hard rules.

Up next

Kotlin Code Smell 27 - Protected Attributes

SOLID Solutions: Beyond Sub-Classification Struggles

More from this blog

Yonatan Karp-Rudin | kotlin for backend developer skills | java for backend developer skills | SpringBoot | Tutorials

57 posts

Experienced Senior Software Engineer passionate about functional programming & Kotlin. Excels in app development, optimization, and team collaboration. Let's create something amazing!