1

At work, we are having 'arguments' about naming styles / conventions. Imagine having a service called UserSettingsService. This has 2 methods, one to get the user settings and one to save. Would you name the method to include what it does exactly, like .getUserSettings(), or just get()?

One argument is that the UserSettings part is implied in the service name. The other argument is that a full method name of getUserSettings() is unambiguos. Is there any 'correct' way to do this?

3

The usual convention is not to repeat the class name in the method

ie Customer.CustomerName == bad

In your case, UserSettingsService sounds like a repository, which only contains user settings. So I would have methods like:

UserSettingsRepository.GetById(string id)
UserSettingsRepository.GetAll()

etc etc

If you have more than one type of settings you might include the type:

SettingsRepository.GetAllUserSettings();

Or you might have a 'resource':

SettingsRepository.UserSettings.GetAll();

Edit

Another method of resolving 'arguments' about naming conventions is to organize a Definitive Resolution in Naming Conventions Session. These session should take place in a pub. In order to propose or object to a naming standard you must first take a drink. Traditionally the oldest member of the team starts the meeting by proposing Hungarian Notation.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.