From the course: Agile Software Development: Clean Coding Practices

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Method and function names

Method and function names

From the course: Agile Software Development: Clean Coding Practices

Start my 1-month free trial

Method and function names

- [Instructor] Let's look at the rules for crafting cleanly named functions and methods. This file contains a bunch of example method names in Ruby. The basic rule is to use a present tense verb as a method name. Methods perform actions and verbs are action words perform, open, close, validate, these are all great examples of action words and they make great method names. Gerund verb forms should be avoided, these verb forms make it unclear when the action is going to happen. Performing, opening, closing, and validating are all examples of gerund verb forms, avoid these. Similarly, past tense verb forms are confusing, because they are referring to actions that occurred in the past. Performed, opened, closed, and validated are all examples of actions that have happened in the past. Avoid these as well. To make these names better, we can prefix is on the gerund verb forms, and has on the past tense verb forms. If you're…

Contents