Global, local naming scheme

Microsoft Windows
Post Reply
User avatar
Posts: 336
Joined: 2021-Jul-12, 1:37 pm

Global, local naming scheme

Post by MigrationUser »

27 Dec 2012 14:09
Ed Dyreen

So there are 3 different ways of saying almost exactly the same thing

Code: Select all

Set object 	= Nothing
variable 	= Null
variable 	= Empty
Not exactly the same, but they should be !

Then there is another problem that when you declare a global variable and redeclare it locally WSH will complain the variable is already used globally. But it shouldn't, a global variable that is redeclared locally should be local making the global variable inaccessible.
I noticed some always append local variables with "my"... That may be not a bad idea...

Code: Select all

Dim variable : variable = something
Function myFunc( myVariable )
	'My code here
End Function
Now I need to think out a good naming scheme to overcome these bad programming styles promoted by MS. And it gets worse, you can't declare the type of variable beforehand so you'll easily loose track of what kind of variable you're actually working with. Is it an array or a collection ?

Code: Select all

' Abbrevations for VBScript 	: long 		: short
' myObject global scope 	: glbMyObject	:  MyObject
' myObject local scope 		: locMyObject	: lMyObject
' myObject STRING 		: strMyObject	: sMyObject
' myObject INTEGER 		: intMyObject	: iMyObject
' myObject BOOLEAN 		: blnMyObject	: bMyObject
' myObject ARRAY 		: arrMyObject	: aMyObject
' myObject COLLECTION 		: colMyObject	: cMyObject
' myObject OBJECT 		: objMyObject	: oMyObject
' myObject CLASS 		: clsMyObject	:  MyObject

I haven't listed all types as I haven't used them yet... But so far, What you guys think of this ?

Last edited by Ed Dyreen (27 Dec 2012 15:16)


#2 18 Jul 2013 13:18
Simon Sheppard

Heres a function IsBlank() for dealing with null/empty variables

Some naming suggestions here:

An argument could be made for using the b prefix for Byte and f (flag) for boolean


#3 05 Sep 2013 14:33

Why does the IsBlank() function at have all of the Exit Functions? They are not needed with they way the function is written.


#4 06 Sep 2013 20:51
Simon Sheppard

^ Good point, I've stripped them out now.

original thread:
Post Reply