2

I have a PHP MVC application and a file table. I need to implement the functionality: mark all as read. The best solution for the code I found so far was to put the actual implementation in a Model/Service/FileService.php

The problem is the class FileService will get bloated really fast with different functionality.

What would be a good solution to avoid bloated Services. Should I created different Services for each action?

1
  • It shouldn't be a concern imo, how much functionality a code file contains as long as the functionality belongs there. You could eventually split it up into more categories of functionality. For example "permissions", "I/O", "attributes" can all be categories.
    – MarioDS
    Apr 9, 2013 at 11:15

1 Answer 1

2

Start by using your FileService class. Once your service gets to bloated, extract classes from FileService and call these from FileService methods.

So, if you now have FileService->writeFile() with the concrete implementation, your future implementation may contain:

function writeFile() {
    new FileWriteService()->doStuff();
}

So, you can still put all file functions in one class while refactoring and grouping the concrete implementations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.