Patterns are awesome. With great powers comes great responsibility.
TL;DR: Don't abuse patterns.
-
Over design
-
Readability
-
Measure the tradeoff of patterns usage.
-
Create solutions based on real-world names (essential) over architecture (accidental).
-
Choose good names.
public final class FileTreeComposite {
// name should be inferred from behavior
}
public final class DateTimeConverterAdapterSingleton { }
public final class PermutationSorterStrategy { }
public final class NetworkPacketObserver { }
public final class AccountsComposite { }
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 { }
It would be very difficult to create automatic detection rules.
A class name with more than one pattern on it, is a warning.
-
Abuser
-
Naming
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.
Code Smell 06 - Too Clever Programmer
Singleton - The root of all evil
Code Smell 38 - Abstract Names
How to Decouple a Legacy System
What exactly is a name - Part II Rehab
Photo by Nathan Dumlao on Unsplash
When you have a hammer, every problem looks like a nail.
Software Engineering Great Quotes
This article is part of the CodeSmell Series.