Reputation: 693
This might be a dumb question. But I do not understand when the access modifier should be set to public and what difference it will make?
Upvotes: 1
Views: 195
Reputation: 16056
That depends on the encapsulation level for your projects/solutions if you feel that resource is more likely to be used internally then set it up as a protected/private/internal resource, if some of those properties may be configured and accessed by an external solution / project then leave it as public.
Encapsulation is good, just think about the way you consume external libraries and how they expose properties, classes,configurations, that's a good exercise to do. Think like an external developer who doesn't know anything about your project implementation, you can ask yourself the following questions:
for me for example talking about IOC, setter injection could be a little bit obscure
Setter injection is just creating a setter property to replace a dependency on a previously instantiated object. I don’t like Setter Injection because it requires extra, hidden steps to prepare an object to execute
look at this post to get the full context as an example, but again this is just an example.
Upvotes: 1