The degree of obeying Law of Demeter in a software application’s design affects its maintenance.
I am wondering whether the same Law or a similar one applies to the number of places one must consult in source code to understand something.
For example, if you define in C++ a macro which expands into a template, expanding in turn to a class which inherits from two classes and has a virtual function – how many source code files do you have to consult to understand what exactly is going on in the original macro expansion.
Or, a simpler case: you #define a macro which expands into a curried function call.
You #define another macro, which curries a further argument in that function call.
Then you’ll have to consult three different places in source code in order to understand the function call.
There seems to be a trade-off between maintenance needs (ability to modify the software by editing at one place and easily grepping the entire source code base to rule out any special cases), and understanding needs (ability to understand everything about a variable or function by referring to its definition/s at only one place; possibly not having to grep for more than one pattern in order to match all uses of that variable even if they hide inside macro definitions).
Did anyone else research and/or write about this issue?