Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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. – MDeSchaepmeester Apr 9 '13 at 11:15

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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