Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 1
    The bool is particularly beneficial if the condition function name would be difficult or possibly misleading (e.g. IsEngineReadyUnlessItIsOffOrBusyOrOutOfService). Commented Sep 12, 2011 at 20:01
  • 2
    I experienced this advice a bad idea: the bool and the condition distract attention from the core business of the function. Also, a style preferring local variables make refactoring harder. Commented Jan 9, 2015 at 9:22
  • 1
    @Wolf OTOH, I prefer this to a function call in order to reduce the "abstraction depth" of code. IMO, jumping into a function is a larger context switch than an explicit and direct couple lines of code, especially if it just returns a boolean. Commented Oct 19, 2016 at 4:44
  • @Kache I think it depends on whether you code object-oriented or not, in the OOP case, the use of member function keeps the design much more flexible. It really depends on the context... Commented Oct 19, 2016 at 6:03