Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / szParam as string identifier... but sz is short for what?

Author
Message
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 18th Sep 2008 00:34
Yeah, as you might know, it is common practise to begin the name of a variable with something defining its type.
Thus we have for instance nValue, meaning value is a natural (positive or zero) value, dwValue, meaning that the value is a dword, and szValue, declaring a string. Most other are clearly shortforms of the type, but what does sz stand for?
I assume that the s is for string, but what's with the z?
The reason I'm asking is because I'm writing some homework in a java course (which I've never used before) and thus wondered if sz was mayhap a c-defined string type, thus making it look very wrong to have a parameter named szParam to a function.

"I kören hörs de brummande busarna Björnligan och Gondolen"
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 18th Sep 2008 00:37
Zero-terminated string, aka a c-style string.

Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 18th Sep 2008 00:42
Ah, ok (should have thought about that ). Thanks.

"I kören hörs de brummande busarna Björnligan och Gondolen"
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 20th Sep 2008 03:49
Personally, I only use 'sz' for an array of characters, ex:

char szMyStr[MAX_STRING] = { 0, };


But I use 'psz' (Pointer to String with Zero) for the pointer method, like:

char* pszMyStr = "";


And as a random note towards this, 's' (alone) can mean Structure or String, so I've stopped placing an 's' in front of structure names, and instead just do (for example):

struct Player
{
char* pszName;
u32 health;
u32 magic;
u32 maxHealth;
u32 maxMagic;
Player *pPrev, *pNext;
};

Like that.


Cheers,

-naota

I'm not a dictator to those that do stuff for me by will. Only those who don't.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 20th Sep 2008 14:54
I don't use it at all - Systems Hungarian is an abomination in my eyes.

David R
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: 3.14
Posted: 21st Sep 2008 22:30
Quote: "I don't use it at all - Systems Hungarian is an abomination in my eyes"


I agree, especially since modern IDEs completely erase the need to be able to tell the type from the variable name on its own (not to mention the fact the name should explain the type / be self-explanatory without Mag. notation)


09-f9-11-02-9d-74-e3-5b-d8-41-56-c5-63-56-88-c0
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 22nd Sep 2008 01:18
Quote: "I agree, especially since modern IDEs completely erase the need to be able to tell the type from the variable name on its own"

Some IDEs don't support it, and others don't display the information right, or put it in an odd place. Why point and click 3~4 times just to find out what kind of variable something is when you can just look at its notation?

Quote: "(not to mention the fact the name should explain the type / be self-explanatory without Mag. notation)"

Imaginary variable - health. Is it a structure, an integer, a float, or a string?


Or
u32 (or f32, or char*) health;

char* for textual representation of it. Hungarian notation is useful - it doesn't HAVE to be used, but I personally prefer it for cleanness.

Cheers,

-naota

I'm not a dictator to those that do stuff for me by will. Only those who don't.
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 22nd Sep 2008 02:17
Quote: "Some IDEs don't support it, and others don't display the information right, or put it in an odd place."


Most people use Visual Studio these days, where it's perfectly accepted to abandon all forms of Hungarian notation. If you're using an obscure IDE or something like Flash, by all means keep using it.


IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 22nd Sep 2008 15:57
Quote: "Imaginary variable - health. Is it a structure, an integer, a float, or a string?"

Who cares what the type is? It's the usage that's important. As long as you manipulate you health variable as if it is health, why care about whether it's a structure, integer, float, string, or something completely different?

That's the difference between systems hungarian (which I will not use) and apps hungarian (which I have a little sympathy with when working with a crappy IDE) - apps hungarian was the addition of a prefix for usage so that you can see when you are doing something wrong (eg prefix with row or col for rows & columns in excel).

Systems hungarian was a misunderstanding of that technique when 'type' was misinterpreted to mean variable type rather than usage type - and it's that that you see when you look at the windows API.

Quote: "Some IDEs don't support it"

Then get a decent IDE. An IDE is supposed to support you, not get in the way.

David R
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: 3.14
Posted: 22nd Sep 2008 18:27
Quote: "Why point and click 3~4 times just to find out what kind of variable something is when you can just look at its notation?
"


Hover a variable name in any decent IDE and it'll tell you the type


09-f9-11-02-9d-74-e3-5b-d8-41-56-c5-63-56-88-c0

Login to post a reply

Server time is: 2024-11-20 16:18:42
Your offset time is: 2024-11-20 16:18:42