There are no hard rules for when to extract boolean conditions into their own function. It depends a lot on the logic happening in the code, how much code there is in the method, how readable itthe code is, if you need to reuse the condition some place else also, etc.
When it's about reusability, the answer it pretty much straight forward. If you need the same conditional check in multiple places, it'sthen the answer it pretty much straight forward. It's a good idea to extract the condition in a function and reuse it.
Other cases are not as clear cut as the reusability situation. Too many conditions in the code can make the code hard to read and can obscure the logic as you need to concentrate on each condition to see the execution paths. You can then extract the conditionconditions in variables to better expose the logic, so your brain doesn't need to focus on each if to evaluate the conditionscondition evaluation (a properly named variable better expresses this). But if you have a lot of these variables, even if the logic would be easier to read with them, you can still have a large fucntionsfunction. Size of the methodfunctions adds to itthem being less readable. So it might now make sense to replace those variables with a function call. You will then have smaller functions, doing less things, thus easier to read. Sometimes you can even replace related conditions with a single function. There is a lot to say about it so I'll stop here and instead leave you with some resources to read that do a far better job at explaining various situations than I could in this answer:
- Martin Fowler's book on Refactoring has a full chapter (Ch. 9) dedicated to simplifying conditionals;
- if you don't have the refactoring book, you can read about the techniques here.