I know it's mostly a psychological question, but what practices exist for a software developer to improve the sense of recognizing basic concepts in the domain and the habit to define simple reusable expressions for them instead of duplicating their definitions all over the code? I'm not speaking about hard-to-learn tools for abstraction but trivial, essential ones like constants and functions that every programming language has. For example, if someone has the task of changing multiple string literals in the code by adding a prefix to them, instead of
"FooBar", they should write (pseudocode):
def prefix = "Foo" prefix + "Bar"
Or if there is a domain-specific derived property of a certain type of entity to compute, introduce a function for that which clearly reflects the nature this derived property:
def boolean isRight(Foo foo) = foo.bar.length > 0
The problem is that even more experienced developers sometimes fail to do this due to lots of possible causes (encountering a new programming language, time pressure etc.). Do you know any good, respectful ways to communicate this with fellow colleagues (not students) in order to let this approach become more instinctive?