Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When defining a class as internal, do you define what would usually be public fields as internal?

When defining a class as internal, do you define what would usually be public fields as internal? Or do you leave them as public? I have a set of classes with public/private methods that I have decided to set as internal. Now, should I change the class' modifier to internal and let the rest of the methods/properties as they are (public/private) or switch them to (internal/private)?

I don't see a big point in changing it to internal, and if by some reason later I want to set them back to public it's going to give a lot of work to have to put them back to public again.

Any other thoughts on this?

like image 843
devoured elysium Avatar asked Jan 18 '26 00:01

devoured elysium


2 Answers

I can't see any reason not to leave them as public, as your class won't be visible to outside assemblies anyway. The only case where I think this might matter is when using reflection over that class.

like image 87
Johannes Rudolph Avatar answered Jan 20 '26 17:01

Johannes Rudolph


If I have a class that is internal, I leave the class members as public (or protected/private of course if that's what they were). I find that often I have classes that I hope I can keep internal that I end up having to expose eventually and switching all the appropriate members back to public is annoying.

like image 44
RationalGeek Avatar answered Jan 20 '26 19:01

RationalGeek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!