Currently, all the logical code has been added in either event subscribers or block classes. It will be better to create a separate counter service that will have all the database access methods as well as other utility functions. This will help in making Drupal related class code more readable.
All the database access methods are currently using the query method which can also be replaced with select, insert and update methods for better control and abstraction.
Comments
Comment #4
gaurav.kapoor commentedAll the scattered code related to accessing databases or external libraries has been moved to service. Only the required code has been kept in the Block and Event Subscriber class.