Prescriptive example from the article:
userRoles.addMember( p ); RoleAssignedEvent.publish( p, roleName );
Seems to have the exact same risk of divergence.
Depending on the language you can (and I have) used decorators/higher order functions to log the invocation of a function with its name and arguments. Zero risk of divergence there, but it was still logging not some kind of event system. The problem of divergence seems to me to be orthogonal.
Re:Logging as a code smell
by seanhunter on Tuesday January 11, 2022 @01:13AM
(#29888187)
So the author proposes we replace it with:
(1) Some code that does a thing
(2) Another line of code that sends an event that the thing happened
(1) Some code that does a thing
(2) Another line of code that logs that the thing happened
And, like in-lined documentation, the code can diverge from the text that says what it does.