GRASP Patterns Overview

What are GRASP Patterns?

They describe fundamental principles of object design and responsibility assignment, expressed as patterns. 
After identifying your requirements and creating a domain model, then add methods to the software classes, and define the messaging between the objects to fulfill the requirements.
The GRASP patterns are a learning aid to help one understand essential object design, and apply design reasoning in a methodical, rational, explainable way. This approach to understanding and using design principles are based on patterns of assigning responsibilities.

Responsibilities and Methods

The UML defines a responsibility as "a contract or obligation of a classifier". Responsibilities are related to the obligations of an object in terms of its behavior. Basically, these responsibilities are of the following two types:
  • knowing
  • doing
Doing responsibilities of an object include:
  • doing something itself, such as creating an object or doing a calculation
  • initiating action in other objects
  • controlling and coordinating activities in other objects
Knowing responsibilities of an object include:
  • knowing about private encapsulated data
  • knowing about related objects
  • knowing about things it can derive or calculate
Responsibilities are assigned to classes of objects during object design. For example, I may declare that "a Sale is responsible for creating SalesLineltems" (a doing), or "a Sale is responsible for knowing its total" (a knowing). Relevant responsibilities related to "knowing" are often inferable from the domain model because of the attributes and associations it illustrates.

POS (Point Of Sale) application is used to explain all the GRASP Patterns.

Let's understand the POS(Point Of Sale) application briefly and then apply GRASP Patterns to POS Application.

Point of Sale (POS) application

Let's consider Point of Sale (POS) application: a Brief overview of POS application.
  1. Application for a shop, restaurant, etc. that registers sales.
  2. Each sale is of one or more items of one or more product types and happens at a certain date.
  3. A product has a specification including a description, unitary price, and identifier.
  4. The application also registers payments (say, in cash) associated with sales.
  5. A payment is for a certain amount, equal or greater than the total of the sale.

How to Apply the GRASP Patterns (General Responsibility Assignment Software Patterns)
Let's discuss five GRASP patterns. There is a separate Post for each GRASP Pattern

    Comments