Discussion on:

6
Comments

Join the conversation!

Follow via:
RSS
Email Alert
You might want to review the summary of access modifiers at the end of the article. Looks like someone mixed a few of them up...
"The five access levels available in both C# and VB.NET provide enough control to cover every design situation."
Ahhh, but I wish there was one more level of access. I would like to create a Friendly List for a method or attribute. For example, let's say I have a factory that creates an object and I want to enforce that only the factory can build the object. It would be nice to mark the constructor as FriendlyWith: Factory...or something to that effect.
I also like to follow the rule that my business objects only know about business, thus nothing about storing themselves, etc. It would be nice to only expose attributes of the class with the storage mechanism. Right now I mark the properties as Internal but that does not stop coders from getting at the data and breaking encaupsluation. . In other words, we end up with encapsulation by convention as opposed to explicit encapsulation. We can achieve this to a degree with interfaces; however I think being able to define a limited scope would be easier to work with.
The access modifiers meanings should be:

public - Access is not restricted.

protected - Access is limited to the containing class or types derived from the containing class.

internal - Access is limited to the current assembly.

protected internal - Access is limited to the current assembly or types derived from the containing class.

private - Access is limited to the containing type.
it is a pretty concise summary.
It is a pretty concise summery
Hi, I'm fairly new to VB, and had a question about modifiers. If I create buttons and when clicked each button opened a different excel file and each button had their modifier set to friend do they or will they ever get mixed up? I don't think they do, but after reading briefly on modifiers I'm not sure? Should I set them to private?

Thanks,
Paul
Keyboard Shortcuts:
Prev
Next
Toggle
Join the conversation
Formatting +
BB Codes - Note: HTML is not supported in forums
  • [b] Bold [/b]
  • [i] Italic [/i]
  • [u] Underline [/u]
  • [s] Strikethrough [/s]
  • [q] "Quote" [/q]
  • [ol][*] 1. Ordered List [/ol]
  • [ul][*] · Unordered List [/ul]
  • [pre] Preformat [/pre]
  • [quote] "Blockquote" [/quote]

Join the TechRepublic Community and join the conversation! Signing-up is free and quick, Do it now, we want to hear your opinion.