There is a common misunderstanding at-least from articles and videos on the topic where the “S” short for the single responsibility principle has been mentioned to mean.

A module should do just one thing.

Although there is a principle like that, this does not capture the entire idea. What the “S” essentially was intended to mean is.

"A module should be responsible to one, and only one, actor."

The term actor refers to a group (consisting of one or more stakeholders or users) that requires a change in the module.

where a module is regarded as a source file. a cohesive set of functions and data structures.

Still here? let’s go further…

A way we could discuss this is in the results. say we have a student class which has the following functions, calculateFees(), calculateClassHours().

public class Student {
    public void calculateFees(){
        //logic
    }

    public void calculateClassHours(){
        //logic
    }
}

This class violates the SRP because those two methods are responsible to two very different actors.

From a bird’s eye-view, no deep thoughts into the matter, the code above will work as intended but will lead to some challenges. ie. making the code reusable,tight coupling etc. and due to the way programs tend to work ie. the larger the code-base -> the proportional logic, making it even harder to understand what is going on.

So… How can we solve?.

A simple way would be to incorporate a design pattern called the Facade, which could mean a figure head for the methods, wherein we move the core logic to a separate class and then make use of those classes in the facade. Well confusing… see below.

// First, we create the student facade
public class StudentFacade {

	public void calculateFees(args1, args2){ // this should have types but we digress

	//perform logic to calculate the fees.
	HourReporter hourReporter = new HourReporter();
	hourReporter.reportHours();

	}

  public void calculateClassHours(args1, args2){
   //logic
	FeeCalculator feeCalculator = new FeeCalculator();
	feeCalculator.calculateFees();
  }
}

public class HourReporter {
    public void reportHours(){
        //logic
    }
}

public class FeeCalculator {
    public void calculateFees(){
        //logic
    }
}

So now the classes are not tightly coupled + the student facade contains very little code. It is responsible for instantiating and delegating to the classes with the functions.

Konclushun.