DEV Community

Discussion on: Do you have a process for naming things?

Collapse
 
jcutrell profile image
Jonathan Cutrell

In OO: Imagine that your methods tell your objects something. Do you want to tell a User to getAllRelatedPosts, or do you want to tell a user to getOwnedPosts?

Similarly, when you know what message you want to send, you can understand a bit more who should receive that message. Telling a file to uploadFile is like telling a human to eatHumanFood. It’s likely that you have objects that can take less specific messages - a Dog can Eat, and a Human can Eat. Maybe both can consume({sustenance: [food, drink]}).

It sounds simple, but name things what they are.

For example, don’t name a file model “Download.” A Download would be an instance of the action of downloading. (This happens to be a bit of a smell - naming objects by an intended action, like UserSignup).