Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 14 in printed book and digital formats -- plus a one-year subscription so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

PDF:

Feature

Gummy Globals

Globals variables are like gum in your hair

Issue: 10.2 (January/February 2012)
Author: Jens Bendig
Article Description: No description available.
Article Length (in bytes): 11,136
Starting Page Number: 35
RBD Number: 10208
Resource File(s):

Download Icon 10208 project.zip Updated: Wednesday, January 4, 2012 at 2:54 PM

Related Link(s): None
Known Limitations: None

Excerpt of article text...

Good code is like a good haircut: it's clean, looks good, and is easy to maintain. But using global variables is like getting gum in your hair. The only way out is with scissors, and the end result is a completely different design.

We've known this for ages, but developers still try to ignore this fact. Maybe that's because global "gum" is so subtle—it gets in a little at a time and doesn't seem so bad at first, but eventually you have a sticky, unworkable mess.

Maybe it is just because developers—in the heat of coding—do not see other solutions for inter-object communication.

In this article I will not show how to completely avoid global variables. I will instead show you how to make them smarter... smart enough to cause fewer problems.

Why Not Use Global Variables?

Let me say it in a concise but abstract manner:

Every access to a variable has a _context_. Global variables deny that.

This denial-of-context is the way global gum works. It corrupts subtly from within.

...End of Excerpt. Please purchase the magazine to read the full article.

Article copyrighted by REALbasic Developer magazine. All rights reserved.


 


|

 


Weblog Commenting and Trackback by HaloScan.com