Kotlin Code Smell 28 - Abstract Names
Yonatan Karp-Rudin
Posted on August 14, 2023
Problem
Solution
- Choose meaningful names.
- Find metaphors.
- Avoid words like abstract, base, generic, helper, data, info, etc.
- 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.
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
💖 💪 🙅 🚩
Yonatan Karp-Rudin
Posted on August 14, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.