0

This is a question about Single Responsability from SOLID that is hurting my mind. When people say about single responsability is it in a macro view or in a micro view like functions?

I mean, is possible to have a class like UserService and has a few functions like save, get, validate related to user or is better to have one class per function?

  • 1
    It's a pretty safe bet that if you have a class like "UserService" ... and that class only has *ONE* method ... then you've *DEFINITELY* got problems with your design ;) "One class per function" is *SELDOM* a Good Idea... In your case, save(), get() and validate() sound OK for "UserService". And UserService might collaborate with "DirectoryService" or "AuthenticationService". – FoggyDay Mar 04 '20 at 01:44
  • What's your level of experience with large-scale projects (i.e. one of tens-of-thousands of users, hundreds-of-thousands of dollars of development costs, or hundreds-of-thousands of lines-of-code)? I found it impossible to figure out DRY, SOLID, and other SE principles when I was getting started in "real" software after having only previously worked on small-scale desktop GUI programs (toys, utilities, etc). If you can tell us your level of experience then we can tailor a personalized answer for you. – Dai Mar 04 '20 at 01:45
  • 1
    https://stackoverflow.com/questions/46541197/does-the-single-responsibility-principle-work-in-oop/46556381#46556381 – Matt Timmermans Mar 04 '20 at 01:48

0 Answers0