Name your procedures well.

For example, a strong verb followed by an object.

Simple procedures are methods on objects that perform some kind of operation on the object. In those cases, the verb alone is good for a name, as it describes the action.

Say you have a Document, and it needs to print. What could be clearer than calling “document.print”?

More complex actions require an additional object. Say you have an object Soup, and you want to add Salt to it. Would anyone object to “soup.addSalt”?

Too often people complicate things. “soup.addIngredient(type flavoring, name “Salt”, measuredBy “pinch”, amount 1)” sounds horrible.  Good luck if you have to expand on that.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: