Chapter 8. Scope and Lifetime of Variables


You will learn about the following in this chapter:

  • Scope

  • Local scope, block scope, and module scope

  • Namespaces

  • Variable lifetime

  • Storage classes

One of the central themes of object-oriented programming (OOP) is encapsulation. As discussed in Chapter 2, "The Basics of Object-Oriented Programming," the idea behind encapsulation is to hide the data and methods associated with an object so they can't be contaminated by outside forces. In some non-OOP languages, making a program change in one section of code has side effects in other, seemingly unrelated, sections of the program. It's like trying to pull on one thread in a spider web and expecting all the other threads to remain unmoved: It just doesn't happen that way.

As an OOP language, Visual Basic .NET provides ways to minimize the impact of these side effects rippling through your code. In this chapter, you will learn how to isolate code and keep it from being contaminated by outside forces. Clearly, this is a good thing and will help you to write better, more bug-proof, code.



Visual Basic .NET. Primer Plus
Visual Basic .NET Primer Plus
ISBN: 0672324857
EAN: 2147483647
Year: 2003
Pages: 238
Authors: Jack Purdum

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net