Re: Global Variable - as string vs object vs record ?

From: Jeremy Collins (jd.collins_at_ntlworld-not.com)
Date: 01/22/04


Date: Thu, 22 Jan 2004 13:25:55 +0000

Lauchlan M wrote:

> (ii) as an object that gets created in the main form's startup, eg

It's largely a matter of personal taste (preference for OO),
and the needs at hand.

What is "X" for? What does it interact with? As the application
grows, do you see a need to add further functionality specific
to "X"? Do you want to "protect" X from being modified in an
invalid way? Do you want to save X's value to the registy etc etc.

FWIW, none of my applications have global variables, just objects
and a file full of consts.

If it doesn't warrant on object of its own, you could consider making X
a property of the main form with "read" and "write" accessors.

TForm1 = class(TForm)
   private
     FX : string;
     procedure SetX(const Value : string);
   public
     property X : read FX write SetX;
   end;

-- 
jc
Remove the -not from email


Relevant Pages

  • Re: Can time be separated from space?
    ... I don't mean this to seem to be a curt reply, but by visible matter I ... such as the Moon, e.g., does not actually interact with our eyes; ... on its state of motion just like its time rate depends on it. ...
    (sci.physics)
  • Re: Dark Matter---where is it?
    ... one proposed candidate for the "Dark Matter" that makes up ... the galactic halo is _massive neutrinos_. ... on the order of a few hunderd kps), and hence would interact even more weakly ...
    (sci.physics.accelerators)
  • Re: Karate Chi Master video... Bullshit
    ... human meat and bone - then it can be detected. ... Chi hasn't been. ... dream of that'll have an effect on matter. ... And if you interact with matter, ...
    (rec.martial-arts)
  • Re: Using public members of a class inside the class
    ... object-oriented programming. ... functions and properties a matter of preference to a certain extent? ... 'End of Class module ...
    (microsoft.public.word.vba.beginners)
  • Re: Karate Chi Master video... Bullshit
    ... human meat and bone - then it can be detected. ... Chi hasn't been. ... dream of that'll have an effect on matter. ... And if you interact with matter, ...
    (rec.martial-arts)