is born or produced with another” 2. “The act of growing together” A programmer-centric definition • Code that must change together in order to maintain the correctness of the system. • A design metric that helps us look at coupling in a system in a more structured way.
on the name of an entity. • Type: when multiple components must agree on the type of an entity. • Meaning: when multiple components must agree on the meaning of specific values. • Position: when multiple components must agree on the order of values. • Algorithm: when multiple components must agree on a particular algorithm. • Execution (order): when the order of execution of multiple components is important. • Timing: when the timing of the execution of multiple components is important. • Value: when the value of two components are related • Identity: when multiple components must reference the entity. N.B. ‘component’ is a relative concept
are closely related. For example, positional arguments in private methods are less problematic than in public methods. Rules of Connascence - The Rule of Locality
def beg(vocalization, repeat) number.times {puts vocalization} end end Cat.new.beg('meow', 4) class Cat def beg(vocalization:, repeat:) repeat.times {puts vocalization} end end Cat.new.beg(repeat: 4, vocalization: 'meow')
set, ast, controller, default_action, to, via, formatted, options_constraints, anchor, options) # some code omitted new set, ast, defaults, controller, default_action, scope[:module], to, formatted, scope_constraints, scope[:blocks] || [], via, options_constraints, anchor, options end • Rule of locality says connascence of position above can be considered acceptable because methods are used once and only locally.