Hello,
I used to write big classes. And for few days, trying to be a better programmer, I am thinking and reading about design.
Considering SRP (Single Responsability Principle), Uncle Bob recommend tiny classes.
So, I began with my big class A (not the real name of course). As starter, considering that it dealt with hosting datas, UI, and IO, I cut the class A into 3 smaller class : A_datas, A_UI and A_IO.
But then I faced a problem : A_UI et A_IO need a read/write access to A_datas (most of) instances variables. For there is no « friend class » in c#, those variables need to be public (or there accessors).
And, having all my datas accessibles for anybody is a little bit disturbing for me.
I could use nested class (A_UI and A_IO into A_datas) but it doesn’t look like the good direction for they would all be too related.
I’m currently considering that having the instance variables of A_datas as public is may be not so dramatic.
Inside my own assembly, it is not dramatic because I can forbid access to A_datas from outside.
But if I work in a team and into the same assembly, it may be …
So, how do you deal with the "small classes" rule ?
Thank you in advance,
I used to write big classes. And for few days, trying to be a better programmer, I am thinking and reading about design.
Considering SRP (Single Responsability Principle), Uncle Bob recommend tiny classes.
So, I began with my big class A (not the real name of course). As starter, considering that it dealt with hosting datas, UI, and IO, I cut the class A into 3 smaller class : A_datas, A_UI and A_IO.
But then I faced a problem : A_UI et A_IO need a read/write access to A_datas (most of) instances variables. For there is no « friend class » in c#, those variables need to be public (or there accessors).
And, having all my datas accessibles for anybody is a little bit disturbing for me.
I could use nested class (A_UI and A_IO into A_datas) but it doesn’t look like the good direction for they would all be too related.
I’m currently considering that having the instance variables of A_datas as public is may be not so dramatic.
Inside my own assembly, it is not dramatic because I can forbid access to A_datas from outside.
But if I work in a team and into the same assembly, it may be …
So, how do you deal with the "small classes" rule ?
Thank you in advance,