Clean code - Naming convension for design patterns
Making it easy for future-code readers to understand
I have been learning design patterns recently. And as a result, implementing them in places that seem fit.
Usually, these patterns are nice. They make code concise and understandable.
This is given that the person reading it knows what the design pattern is.
So to mitigate this problem my current approach is.
To prefix name of class with the design pattern.
<ClassName>Factory. (In case of simple factory:
- Chain of Responsibility:
<ClassName>Chain. Method name:
You get the point.
Hopefully, this would make it easy for person reading the code to understand how to use it in future.
If there are more tthat can be done, please mention in the comments below. I’ll be happy to know more approaches.
Photo by Glen Carrie on Unsplash ↩