Saeid
Saeid

Reputation: 693

For a resx resource file, why should I use an internal or public access modifier?

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

Answers (1)

pedrommuller
pedrommuller

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:

  • is this piece of code worth to external developers to know about it?
  • do I need a pre-configuration on this code?
  • is my implementation clear enough so anybody understand it just by looking at the code implementation?
  • does the code enforce certain policies/requirements?
  • does my code have obscure implementations?

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

Related Questions