Don’t use conjunctions in method names.

Two great ideas taste great together, but not in a method.

Words like for, and, but, or, yet, so, etc can be used to extend ideas, qualify statements, apply filters, and other things. When you see these in a method name, it’s a sure sign the method is trying to do more than one thing.

A method should really only have one job, so when you see conjunctions, it’s a red flag that the previous developer piled too many things into one method. Try to refactor this into two or more methods.

Methods can then be chained together as needed. The individual, smaller methods will now be easier to re-use for other purposes. These new methods will also be easier to test.

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 )

Facebook photo

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

Connecting to %s

%d bloggers like this: