Jump to content
  • Advertisement
Sign in to follow this  

Class Naming

This topic is 4748 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have to admit that I am not very good at creating good names for my classes (yet). When I think of a good name, I look at the following: Is it clear? Is the purpose of the class communicated through the name? Is it consise? (Network vs NetworkObject) Is it short and easy to type? Specifically, I am having trouble deciding on a name for the following class: A pure virtual base that contains a message handler and which specific classes are derived. The base class is not a message handler itself, it HAS a message handler, so obviously that is out. I could go for a name like Receiver or Dispatcher, but I feel like that is too vague. The primary purpose of the class is to allow for Network Messaging, so I feel like Networking should be incorporated in the name, but I don't like just shoving "Network" infront of another word to accomplish that (eg: NetworkDispatcher, NetworkEntity, ...) Maybe someone else has come to a similar dilema in the past and created an elegant solution to the naming problem that just eludes me... Obviously this is hardly a critical decision, but It would seem like effective class naming is one of the more important skills to develope sooner rather then later.

Share this post


Link to post
Share on other sites
Advertisement
- If this is C++, you can end the name in 'Interface' to indicate that the class is pure virtual.

- If you don't feel like using prefixes such as 'Network', you can always use namespace partitioning, so you class ends up in namespace 'Network' or 'Net' or some similar.

- If your base pure virtual class doesn't do anything beyond message handling, you can make it just Net::MessageHandlerInterface or something like that.

- If it has provisions for some additional related functionality, my guess is that Net::DispatcherInterface would probably do.

The developers I work with make a great deal of naming their classes properly up front; however, for my own code, I found through trial and error that it often works best to rename and restructure when you finally get a clear idea of what meaning the name should convey. Until then, just go with whatever name seems okay.

Share this post


Link to post
Share on other sites
I'd go with shoving it in a namespace, such as Network, and then if you can't be bothered to write that out every time, you can create an abreviation namespace such as just Net or even just N.

Oh ya, and short vs. clear, I'd go with the clear name any day.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!