A class with too many responsibilities

In this example, we are going to create the case for an application that is in charge of reading information about events from a source (this could be log files, a database, or many more sources), and identifying the actions corresponding to each particular log.

A design that fails to conform to the SRP would look like this:

Without considering the implementation, the code for the class might look in the following listing:

# srp_1.pyclass SystemMonitor:    def load_activity(self):        """Get the events from a source, to be processed."""    def identify_events(self): """Parse the source raw data into events (domain ...

Get Clean Code in Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.