What are GRASP principles?

Answer

GRASP (General Responsibility Assignment Software Patterns) are nine principles for assigning responsibilities to classes and objects, defined by Craig Larman: (1) Information Expert: assign responsibility to the class that has the information needed to fulfill it. Order should calculateTotal() because it knows its items; (2) Creator: assign class B to create instances of class A if: B contains A, B records A, B closely uses A, or B has initialization data for A; (3) Controller: assign responsibility for receiving and handling system events to a non-UI class — the "controller" in MVC/MVP; (4) Low Coupling: assign responsibilities to minimize dependencies between classes; (5) High Cohesion: assign responsibilities to keep classes focused and manageable; (6) Polymorphism: use polymorphism when behavior varies by type — avoid type-checking conditions; (7) Pure Fabrication: create a class with no direct real-world counterpart to achieve low coupling/high cohesion (e.g., DatabaseAccessObject, Service, Repository); (8) Indirection: add an intermediate object to mediate between components to reduce coupling (e.g., Controller, Adapter, Facade); (9) Protected Variations: identify points of likely variation, create stable interfaces around them. Most important: Low Coupling + High Cohesion + Information Expert. These guide day-to-day decisions about where to put code — they're more practical than GoF patterns for everyday design.