When programming in Prolog, we must pick two kinds of names:
A good predicate name makes clear what each argument means. By convention, underscores are used in names to separate the description of different arguments. This is because underscores_keep_even_longer_names_readable
, whereas mixingTheCasesDoesNotDoThisToTheSameExtent
.
Examples of good predicates names are:
parent_child/2
person_likes/2
route_to/2
Note that descriptive names are used. Imperatives are avoided. Using descriptive names is advisable because Prolog predicates can typically be used in multiple directions, and the name should be applicable also of all or none of the arguments are instantiated.
Mixed capitalization is more common when selecting names of variables. For example: BestSolutions
, MinElement
, GreatestDivisor
. A common convention for naming variables that denote successive states is using S0
, S1
, S2
, ..., S
, where S
represents the final state.