- Published on
[1] I wish I knew this earlier: The Art of Naming
I would always name my services / interfaces / handlers and everything else you can think of with the suffix ....Service.
Why?
I guess... Lack of maturity. Lack of experience. Nobody told me otherwise?
For instance:
UserServicefor managing user accounts.SessionServicefor handling user sessions.PermissionServicefor governing user permissions.
I really hope you can see that doesn't the Service part seem redundant? It doesn't enhance clarity. In fact, it often obfuscates the real purpose of the entity.
I wish I knew earlier that naming can be more descriptive, and there are alternatives that often make more sense.
To help fellow developers, here's a quick guide:
1. Third-party Service Integrations:
- Instead of
UserService, consider:UserManagerUserHandlerUserConnector
2. Processing or Logic:
- Instead of
UserService, consider:UserModifierUserHandlerUserValidator(for validation logic)
3. Data Storage or Retrieval:
- Instead of
UserService, consider:UserStoreUserRepositoryUserArchive(if it's mainly for historical data)
4. Components that Transform Data:
- Instead of
UserService, consider:UserTransformerUserAdapterUserConverter
5. Components Handling Caching:
- Instead of
UserService, consider:UserCacheUserCacheProvider
6. Use-case Driven Naming:
- Instead of
UserService, consider:UserAuthenticatorUserRegistrationProcessorUserPasswordResetter
7. Configuration Components:
- Instead of
UserService, consider:UserConfigProviderUserSettings