I’m developing this web application where a users actions is logged at certain places. I initially wrote the logging features into the Main Users Service. I’m currently looking at it now and will be refactoring out the functionality to separate concerns. While to me, at the time, logging a Users action is from a natural standpoint looked like it belonged to the Users service, a more thorough look at it made it clear that the Logging functionality should be it’s own Service.
Don’t see where the mix up of concerns is?
Here’s a list of functionality my Users Service class provided.
- Creating Users.
- Reading Users.
- Updating Users.
- Deleting Users.
- Fetching a User by Id.
- Searching through Users.
- Counting total search results (I utilise scroll pagination for my record list and dojo datagrid needs to know the total number of records it needs to scroll up to).
Think that the Log functionality is tied in directly with Users since you can’t have one without the other? Well, I did! To the point where the Model automagically handled logging by using the DbTable for the log. At that time, I accepted in my head that Users Log was part of Users and besides, it’s logging; my focus wasn’t on that particular “minor” detail.