Object-Oriented – Term for Accessor Method Returning Boolean

object-orientedterminology

I seem to recall that there is a specific term for an accessor method that returns a Boolean value but it escapes me. For example: typical methods such as:

class Example {
    bool isDirty();
    bool hasChildren();
    bool isValid(SomeType obj);
};

I will also settle for such a term as applied to a non-member functions.

Best Answer

A function from some type T to Boolean is usually called a predicate, and if you want to make clear that it is a method of an object, i.e. that it takes the implicit this argument in addition to its other arguments, then you could call it a predicate method. If it takes no other arguments except the implicit this argument, then you can call it a predicate property.

See for example Predicate<T> in .NET and e.g. javax.sql.rowset.Predicate or com.google.common.base.Predicate in Java.

Related Topic