Joseph's programming tidbit #1 - scope in .NET

No, I'm not talking about mouthwash.

There are five scopes in Visual Basic.NET
  1. Private
  2. Friend
  3. Protected
  4. Public
  5. Protected Friend
An important thing that I learned about scope in the context of inheritance:It is important that the parent class of a child class be public, otherwise the child class won't be able to be instantiated. There is however, an instance when this is Ok. And that is when a class factory method is available to instantiate the class. A factory method is a static method that instantiates members of a separate class.

Another sly nuance exception to scope arrises from nested classes. Private class level variables of a class that is nested within another can be accessed by the parent class. Ah ha! There not so private after all! Kinda like the neighbor who has a view into your living room from theirs. Like my neighbor for example.

Singelton class: A class designed such that only one instance of that class exists at any one time. I typically accomplish this in my code with a DefInstance static method which hold the one instance of the class that I want the rest of the project to access.
-Joseph

Comments

Popular posts from this blog

How to Create and Run Tableau Bridge on Linux Containers

RAM Disks do not speed up Visual Studio

Outlook tip: Turn off Email Contact Pictures