DEV Community

Yonatan Karp-Rudin
Yonatan Karp-Rudin

Posted on • Originally published at yonatankarp.com on

1

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

Enter fullscreen mode Exit fullscreen mode

Right

class Schedule {
    // ...
}

class Portfolio {
    // ...
}

class NoteBook {
    // ...
}

class Journal {
    // ...
}

class Vehicle {
    // ...
}

Enter fullscreen mode Exit fullscreen mode

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.


I hope you enjoyed this journey and learned something new. If you want to stay updated with my latest thoughts and ideas, feel free to register for my newsletter. You can also find me on LinkedIn or Twitter. Let's stay connected and keep the conversation going!


Credits

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more