Skip to main content
OBJECT-ORIENTED-PROGRAMMING5 MIN READ

Put behavior where the data lives

Assign a method to the class that has the information needed to perform it.

The move: ask who knows enough to do the work. GRASP Information Expert is a responsibility-assignment rule: put a behavior on the class that has the information needed to fulfill it. This keeps logic close to the state it relies on and stops your design from becoming a pile of records plus one giant service. Signal 1: parameter drag If a method receives an object only to pull out several fields, that object may be the better owner of the behavior. Signal 2: duplicated rule checks If two services repeat the same if invoice overdue and customer is not exempt…

Read the full lesson

Sign up free — one personalized lesson every day, matched to your role and goals.

Already have an account? Sign in

← Back to library
Contact us