What are Different Types of Responsibility in OO Design


In object-oriented (OO) design, responsibilities refer to the tasks or functions that a class or object is responsible for carrying out. The following are different types of responsibilities in OO design :

  1. Functional Responsibilities: These are the tasks that a class is responsible for carrying out. For example, a BankAccount class may have functional responsibilities such as deposit, withdraw, and balance inquiry.

  2. Informational Responsibilities: These are the tasks related to data management, such as storing, retrieving, and manipulating data. For example, the BankAccount class may have informational responsibilities like storing the account balance and account holder information.

  3. Behavioral Responsibilities: These are the tasks related to how an object interacts with other objects or the system as a whole. For example, the BankAccount class may have behavioral responsibilities like sending notifications to the account holder in case of a low balance.

  4. Collaborative Responsibilities: These are the tasks related to how an object interacts with other objects to accomplish a larger task. For example, the BankAccount class may have collaborative responsibilities such as working with a Transfer class to transfer funds between accounts.

  5. Interface Responsibilities: These are the tasks related to defining the interface of a class or object. For example, the BankAccount class may have interface responsibilities such as defining methods for deposit, withdraw, and balance inquiry.

In general, good OO design involves assigning responsibilities to classes and objects in a way that promotes high cohesion and low coupling, meaning that each class should have a clear and specific purpose and should not be overly dependent on other classes or objects. 

       

Advertisements

ads