简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM