Patterns are awesome. With great powers comes great responsibility.
TL;DR: Don't abuse patterns.
Problems
Over Design
Readability
Solutions
Measure the tradeoff of patterns usage.
Create solutions based on real world names (essential) over architecture (accidental).
Choose good names.
Sample Code
Wrong
public final class FileTreeComposite {
//name should be inferred from behaviour
}
public final class DateTimeConverterAdapterSingleton {
//
}
public final class PermutationSorterStrategy {
//
}
public final class NetworkPacketObserver {
//
}
public final class AccountsComposite {
//
}
Right
public final class FileSystem {
// These names map 1:1 to real world concepts
}
public final class DateTimeFormatter {
//
}
public final class BubbleSort {
//
}
public final class NetworkSniffer {
//
}
public final class Portfolio {
//
}
Detection
It would be very difficult to create automatic detection rules.
A class name with more than one pattern on it, is a warning.
Tags
Abuser
Naming
Conclusion
Chose when to apply a pattern solution. You are not smarter for using too many patterns. You are smart if you choose the right opportunity for everyone.
Relations
More Info
What exactly is a name - Part II Rehab
Maxi Contieri ・ May 23 '21
Credits
Photo by Nathan Dumlao on Unsplash
When you have a hammer, every problem looks like a nail.
Software Engineering Great Quotes
Maxi Contieri ・ Dec 28 '20
This article is part of the CodeSmell Series.
How to Find the Stinky parts of your Code
Maxi Contieri ・ May 21 '21
Last update: 2021/07/09
Top comments (0)