Global objects with local variables

Posted by Albert Gareev on Jul 12, 2007 | Categories: Notes

Variables and Namespace

I’ve recently had a noticeable conversation explaining a junior colleague of mine about local variables in hierarchy of calls, namespace and scope, and how this concept aligns with Object-Oriented Programming, dynamically created / released object instances, in particular.

Below is the scheme I ended with.

Lifespan of objects

If lifespan of a variable is defined by its scope, lifespan of an object is defined from when it’s been created till when it’s been released. However, if an object was not explicitly released, it might be (not guaranteed!) released automatically when the last pointing to it variable goes out of scope (read more about Garbage Collector objects).

  • Leave a Reply

    * Required
    ** Your Email is never shared

Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported
This work by Albert Gareev is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported.