This applies to all types of libraries. Not just SRP.
Organizing classes / functions can be a headache, but there really are just a few things you need to keep in mind.
- Plan.
- Define and save the correct convention name for files, classes, folders, methods / functions and variables.
- Break your classes into namespaces or, at least, into subfolders of the main muscle groups of the system.
- Document: internally (good comments, file headers, and the public method lists) and externally (wiki, readmes, excel, something)
By 2, I mean: /library/muscleGroup/useType_nameOfClass.php for files / folders where useType is something like "factory" "abstract" "data / dto" or any templates that you use. Then in each file the class should be the same as nameOfClass, and each method name should strictly follow the pattern. [Action][on what][with what conditions] and save the list of actions and "what" and stick to their RELIGION.
Do this and you won’t be able to duplicate functionality, as you can easily find the classes and methods you need for the things you want. Because they have logical names like Get_User_ById and Get_Transactions_ByNewest or Combine_Ingredients_FromRecipes .
This last one may contain the comment above:
List of example actions: (should be fairly general and apply to any application)
- Receive
- Set
- Delete
- Move
- Combine
- Combine
Sample list "On": (must be a specific application)
- User
- Ingredient
- Recipe
- Measurement
- Resolution
- Mark
- Ad
source share