If a function is being used to process incoming results, I believe an SRP violation exists if it contains all the logic:
def process_response(response):
'''Process the results of the web request'''
# logic to parse response
# logic to format response
# logic to write response
This function is doing a lot, and its clear. But if the logic was separated out, such that the function composed of calls:
def process_response(response):
'''Process the results of the web request'''
parsed = parse_response(response)
formatted = format_response(parsed)
save_response(formatted)
Even though the function is calling several functions to perform independent actions, do we say that process_response
has a single responsibility? I suppose it is relative to the level of abstraction you give to the current function. Explicitly stated, it is responsible for calling the parser and calling the formatter and calling the saver. When explained as such, it appears that process_response
has several responsibilities. However, when stated it's responsible for "managing the processing workflow", it appears as a single responsibility.
I would think it impossible to have no functions that are not composed of calls when developing a system. Therefore, is it safe (or correct) to view a composed function as having a single responsibility of executing its callees?