Let's say we have a typical service class method who does few things, input validation, db object retrieval, some business logic execution and then saving and returning record to user. This is irrespective of any language we are using.
methodA(args1, args2, args3) {
returnValue1 = validateArgs(args1, args2, args3)
returnValue2 = dbObjectRetrieval(args1)
businessLogicValidatorMethod(returnValue2, args1, args2, args3)
enrichArgs(args1, args2, args3)
returnValue3 = saveArgs(args1, args2, args3)
return returnValue3;
}
Now when we say that one method should only do one thing, the above method is clearly doing more than one things, Needless to say all the business logic that goes into the picture. I can understand that for methods like validateArgs, dbObjectRetrieval, businessLogicValidatorMethod it is very easy to do one thing, in the sense
a. validateArgs should not go to db, instead all the required data should be passed and method argument except some environment configurations may be.
b. dbObjectRetrieval should not try to validate anything and either returns the data or throws exceptions (lets say in the case of not found)
similarly for other methods.
This will have obvious benefit that these single responsibilities function (where there are not side effect of getting input form somewhere else but inputs are passed as params) can be reused across the application.
But What if some functionality of methodA is duplicated in methodB. should we move that logic into another methodC and both methodA and methodB start calling methodC? How do you make sure that one function can not be broken down any further?
the above method is clearly doing more than one things
-- I don't think that's clear at all. Since you haven't given methodA a meaningful name, it's difficult to evaluate whether or not it does one thing. "Doing one thing" doesn't mean every method contains a single line of code.