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.

Predicate methods

Predicate methods

From the course: Agile Software Development: Clean Coding Practices

Start my 1-month free trial

Predicate methods

- [Instructor] Many of the systems that we work on contain intricate logic which specifies how items should be handled. For example, a payroll system likely has very specific rules that decide when someone should be paid, how much they should be paid and how much money should be kept out of their paycheck to pay taxes on their behalf. Many of these decision points will be coded into an if statement. And the Boolean logic in these if statements can get rather complex. In order to understand what the program is doing, the reader has to look at the complex chain of Boolean operations and if statement to get a good understanding of what the program is trying to determine. This makes it really challenging for readers to get a good sense of what's going on. A good strategy for keeping these if statements clean and easy to understand is to use a predicate method. A predicate method returns a Boolean value and is…

Contents