Just as there is a naming convention for the Observer pattern (or rather, a naming convention for events in languages such as C#) using Event/Handler passing EventArgs and such, are there naming conventions that you use to easily highlight other patterns in your code?
edit: I originally wanted to ask about the Strategy pattern, but figured it would be helpful to know about any other conventions that might exist for common patterns as well.
File naming best practices: File names should be short but descriptive (<25 characters) (Briney, 2015) Avoid special characters or spaces in a file name. Use capitals and underscores instead of periods or spaces or slashes. Use date format ISO 8601: YYYYMMDD.
A naming convention is a convention (generally agreed scheme) for naming things. Conventions differ in their intents, which may include to: Allow useful information to be deduced from the names based on regularities.
Project lead's last name or initials. File creator's last name or initials. Project name/acronym.
I usually let the postfix of the class designate if it uses some of the ideas of a pattern - ie. all my ViewModels end in ViewModel... My Views end in View and so on. It is really nice for the patterns you use all the time (Factory, ViewModel, Strategy spring to mind). Some are more intrinsic (I have yet to name a class MonoState) - I guess it has to do with the main responsebility of the class - or that I don't name it after an implementation-detail (Monostate is an implementation detail in my book). If what it does fits with the pattern it emulates/encompasses - It gets a postfix with the name of the pattern.
If nothing else, it helps readers of my classes to figure out some of the reasoning in the implementation with me writing no comments. I try to use the general name (no C#-specific names) if I can - although, ViewModels are somewhat specialized to the WPF world.
I have lots of IPricingStrategy, ICustomerViewModel and so on across my code-base.
Hope that makes as much sense as it did to me while writing it :-).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With