4 ms·
What do you consider large? I think classes without internal state, can be large and still simple to understand. But if many mutable fields and internal constr
by cutemonster 7y ago
What do you consider large?
I think classes without internal state, can be large and still simple to understand. But if many mutable fields and internal constraints, then things can get complicated. Better keep such classes smaller
- mark-r 7y agoI would never argue smaller isn't better. But the code I work on every day tends to have much larger classes than that.
- fetbaffe 7y agoYes, key point is to separate classes if they have state or not. I have a simple convention in my code base, a repository does not have state, a service depends on repositories & can have state, thus a repository can have lots of methods (different ways of retrieving data) & a service is specialized & only have small number of methods. If an existing services does not match exactly what you need to do, you write a new service and reuse the same repositories.