Wednesday, 17 August 2016

Class naming chaos




I often struggle with deciding how to name a class. Not so much because the class's purpose is unclear, but because of names like xxx***Controller***, xxx***Manager***, xxx***Info***, xxx***Helper***, xxx***Util*** etc that I see everywhere.



If I have a class that uploads some stuff over HTTP, I tend to name it HttpUploader or something on those lines. I have seen many instances where a similar class being named HttpUploadManager, HttpTransmissionController, HttpUploadHelper and so on.



I am sort of confused as to when to use Controller, Manager, Info etc. Is there any article or book that can help me become a better namer of classes?



PS: Also, a name like HttpSender sounds pretty anemic when compared to HttpTransmissionController or HttpDispatchManager :P



Answer



The popular opinion on SO seems to be to avoid the use of suffixes like Manager, Info, Helper, or Util.



See: Smelly Class Names and Class names that need refactoring.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...