Posts

Showing posts with the label functional-interface

Naming convention of @FunctionalInterface

Naming convention of @FunctionalInterface By convention, types should be named by nouns, that's ok. However, @FunctionalInterface is a special type - object type that acts like function/method. In case of function I feel like it's more natural to choose a verb e.g. decorate.apply(o) instead of noun decorator.apply(o) . And there is also nouns expressing an activities e.g. decoration.apply(o) . @FunctionalInterface decorate.apply(o) decorator.apply(o) decoration.apply(o) If I look at java.util.function package all the functions are named by nouns: Function , Operator , Consumer , Supplier , ... Should I prefer nouns , verbs or nouns expressing verbs ? Function Operator Consumer Supplier Class names are nouns, method and function names are verbs - if you see something having noun name in spec - it means somewhere there's a class or an interface having such name. Whenever you have an object - it's identified by nouns, whenever you have a beha...