SOFTWARE ENGINEERING

SOFTWARE DESIGN

DESIGN PATTERNS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
The Single Responsibility Principle says
A
Favor composition over inheritance.
B
A class should have only one reason to change.
C
Depend upon abstractions.Do not depend upon concrete classes.
D
Classes should be open for extensions, but closed for modification.
Explanation: 

Detailed explanation-1: -The idea behind the SRP is that every class, module, or function in a program should have one responsibility/purpose in a program. As a commonly used definition, “every class should have only one reason to change". The class above violates the single responsibility principle.

Detailed explanation-2: -Single-responsibility Principle (SRP) states: A class should have one and only one reason to change, meaning that a class should have only one job. For example, consider an application that takes a collection of shapes-circles, and squares-and calculates the sum of the area of all the shapes in the collection.

Detailed explanation-3: -The single-responsibility principle (SRP) states: “There should never be more than one reason for a class to change.” When changing a class, we should only change a single functionality, which implies every object should have only one job.

There is 1 question to complete.