quiz image

GRASP Object Design: Inputs, Activity, and Outputs Explanation

SprightlyVision avatar
SprightlyVision
·
·
Download

Start Quiz

Study Flashcards

Questions and Answers

What is the purpose of local variables in programming?

To ensure data is available only as long as needed within a limited scope

How does global visibility differ from local visibility?

Global visibility allows data sharing between different classes, while local visibility restricts access within a limited scope

Why can global visibility create problems if not used carefully?

It leads to unintended interactions or dependencies between different parts of the system

In object-oriented systems, what is the least common form of visibility?

<p>Global visibility from A to B</p> Signup and view all the answers

What is the purpose of creating class definitions from Design Class Diagrams (DCDs)?

<p>To generate basic class definitions using UML tools</p> Signup and view all the answers

How does the sequence of messages in an interaction diagram translate into method definitions?

<p>It translates to a series of statements in the method definitions</p> Signup and view all the answers

Study Notes

Local Visibility

  • Local variables are declared within a method or block and have a limited scope
  • They are created when the method or block is executed and destroyed when the method or block completes
  • This ensures data is only available for as long as it is needed, reducing the risk of accidental or unauthorized access

Global Visibility

  • Global visibility refers to the visibility of variables or objects declared at the global scope
  • Global variables or objects can be shared between different classes, methods, or modules in the system
  • They provide common or shared data that needs to be accessed by multiple parts of the system
  • However, global visibility can create problems if not used carefully, leading to unintended interactions or dependencies between different parts of the system

Implementation in Object-Oriented Language

  • Implementation involves writing source code for class and interface definitions, method definitions, and other elements
  • Class definitions can be generated from design class diagrams (DCDs)
  • Method definitions can be created from interaction diagrams
  • Collection classes and exceptions and error handling need to be considered in the implementation process

GRASP (General Responsibility Assignment Software Patterns)

  • GRASP is a set of guidelines for assigning responsibilities to classes and objects in object-oriented design
  • There are nine patterns in GRASP: Creator, Information Expert, Low Coupling, Controller, High Cohesion, Polymorphism, and Pure Fabrication
  • Each pattern helps to assign responsibilities to classes and objects in a way that promotes maintainability, adaptability, and scalability

GRASP Patterns

Creator

  • Assigns the responsibility of creating objects to a centralized class
  • The creating class has a relationship with the created class
  • Simplifies object creation, encapsulates object creation, and centralizes object creation

Information Expert

  • Assigns the responsibility of performing a task to the class that has the most relevant information
  • The class that has the information needed to fulfill a task should be responsible for performing that task
  • Reduces complexity and improves modularity and maintainability

Low Coupling

  • Aims to reduce the degree of interdependence between different modules or components
  • Minimizes the impact of changes to one part on other parts of the system
  • Keeps interfaces simple and well-defined, and minimizes the amount of information shared between components

Controller

  • Manages and coordinates the flow of information between different components
  • Assigns the request from the UI layer to domain layer objects
  • Receives requests from the UI layer and coordinates with other objects to fulfill the request

High Cohesion

  • Ensures that each module or component has a well-defined and focused responsibility
  • Each part of the system should have a clear and specific purpose
  • Group related functions and data together, and ensure each component has a single responsibility

Polymorphism

  • Allows objects to take on multiple forms or behaviors
  • Achieved through inheritance, where a subclass can inherit and override the methods of its superclass
  • Enables objects to be treated as if they were of a different class, but with additional or different functionality

Pure Fabrication

  • Creates objects that do not represent real-world objects or concepts, but instead serve as an artificial abstraction of a particular behavior or functionality

  • Creates an object solely for the purpose of performing a specific task or operation that doesn't fit naturally with any other objects in the system### Pure Fabrication

  • Creating a pure fabrication allows for better separation of concerns in a system and reduces complexity of existing objects.

  • Example: Creating a fabricated DBStore class to handle database operations instead of putting it in the Shape class, making Shape incohesive.

Indirection

  • Introduces an intermediate object or layer between two objects to reduce coupling between them.
  • Allows objects to interact without directly knowing about each other.
  • Example: Polymorphism illustrates indirection, where Employee class provides a level of indirection to other units of the system.

Protected Variation

  • Designs the system to protect internal components from external variations or changes.
  • Introduces an intermediate object or layer to handle interactions with external components.
  • Example: Introducing a Data Converter object to protect the internal components of a system from changes in external data sources.

Visibility

  • Refers to the ability of an object to "see" or have a reference to another object.
  • Related to the issue of scope.

Attribute Visibility

  • Refers to the visibility of properties (attributes) of a class.
  • Attribute visibility exists when one object is an attribute of another.
  • Levels of attribute visibility:
    • Public: accessible to all other objects in the system.
    • Private: only accessible and modifiable by the object that owns it.
    • Protected: accessible and modifiable by the object that owns it and its subclasses.

Parameter Visibility

  • Refers to the visibility of input parameters passed between objects or methods.
  • Parameter visibility exists when one object passes a parameter to a method of another object.
  • Levels of parameter visibility:
    • Public: visible to all objects and methods in the system.
    • Private: only visible within the method or object that owns it.

Local Visibility

  • Refers to the visibility of variables or objects declared and used within a method or block of code.
  • Local visibility exists when a local object is declared within a method of another object.
  • Important for maintaining encapsulation and data privacy in object-oriented programming.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

More Quizzes Like This

Grasp the Essence of Islamic Gratitude
6 questions
GRASP Patterns in Object Design
5 questions

GRASP Patterns in Object Design

InestimableRainforest avatar
InestimableRainforest
GRASP Patterns and Responsibilities
30 questions
Use Quizgecko on...
Browser
Browser