LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


View Poll Results: what do you do with your variables?
make them funny, tributes etc 1 3.23%
strictly program related 24 77.42%
letters and numbers, keep that code small! 0 0%
mix of em all! my programs are such a mess... 6 19.35%
Voters: 31. You may not vote on this poll

Reply
  Search this Thread
Old 12-17-2003, 07:01 PM   #1
titanium_geek
Senior Member
 
Registered: May 2002
Location: Horsham Australia
Distribution: elementary os 5.1
Posts: 2,479

Rep: Reputation: 50
variable names in your code (fun)


what do you guys do with your variable names?
just curious.

titanium_geek
 
Old 12-17-2003, 08:08 PM   #2
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
When I'm doing real programming, I try to use meaningful variable names. For a while I attempted using Hungarian notation, but lapsed out of it. Too bad there's no really standard practice for that; it can be helpful to remember what type something is later on in the program, though. Some obvious exceptions, though, like i, j, k, for loops, or temp for temporary storage.

If I'm just hacking together something simple, I don't bother with descriptive variable names. foo, bar, ack, blah, and so on. Sometimes it's fun to give them personal names, like Fred, Jim, Steve, etc., so they can have an identity

Man, I need to do some programming. Haven't touched the stuff in almost a year...

Last edited by wapcaplet; 12-17-2003 at 08:10 PM.
 
Old 12-17-2003, 10:49 PM   #3
Kumar
Member
 
Registered: Sep 2003
Location: Pune, India
Distribution: Red Hat
Posts: 106

Rep: Reputation: 15
It depends on the type of program I am working on. If it's just for testing something or new ideas, I use simple variables. But while working on a project, I make sure that the variable names are meaningful. Hungarian notation, I guess is not a great idea (Maybe coz it was developed by M$ )

Last edited by Kumar; 12-17-2003 at 10:50 PM.
 
Old 12-18-2003, 04:54 AM   #4
titanium_geek
Senior Member
 
Registered: May 2002
Location: Horsham Australia
Distribution: elementary os 5.1
Posts: 2,479

Original Poster
Rep: Reputation: 50
Well, one of my latest programs (in java) has a flowlayout flem, gridlayout grim,
a pannel called pain... (pane..) I also have a thelps (for the help stuff) who was a character in one of the books I wrote in elementary.
I sometimes name my vars in spanish, to avoid restricted words.. such as new etc.

hahaha.

titanium_geek
 
Old 12-18-2003, 12:02 PM   #5
WindowsBurner
Member
 
Registered: Nov 2003
Location: In chaos
Distribution: OpenSuse
Posts: 293

Rep: Reputation: 30
No matter what language im using or what program im writing I always use descriptive names.Whether I am writing a game engine or writing a program to test an idea Its program relate variable names for me.
 
Old 12-18-2003, 12:09 PM   #6
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Program related and descriptive. Often more than 20 characters.
 
Old 12-19-2003, 02:58 AM   #7
nephilim
Member
 
Registered: Aug 2003
Location: Belgium
Distribution: Debian (server), Kubuntu (desktop)
Posts: 248

Rep: Reputation: 30
Just think about the guy that comes after you and has to read your code, than you have your answer quite quickly. Always use descriptive variable names to keep your code readable!
 
Old 12-19-2003, 04:07 AM   #8
Tarts
Member
 
Registered: Feb 2003
Distribution: Slackware 9.1 (exclusively) ;)
Posts: 344

Rep: Reputation: 30
Quote:
From GNU.org
auto accident;
register voters;
static electricity;
struct by_lightning;
void *where_prohibited;
char broiled;
short circuit;
short changed;
long johns;
I go for short and descriptive.

Tarts
 
Old 12-19-2003, 06:26 AM   #9
LinuxLala
Senior Member
 
Registered: Aug 2003
Location: New Delhi, India
Distribution: Fedora 7
Posts: 1,305

Rep: Reputation: 45
I keep my variable names simply program related. That keeps the record straight and the program can be easily understood by anyone.

Learnt a good lesson when a few years ago I messed up with the names of my variables and at a later stage could myself not understand(literally) which variable represented what
 
Old 12-21-2003, 10:41 PM   #10
teval
Member
 
Registered: Jul 2003
Location: Toronto, Canada
Distribution: Gentoo
Posts: 720

Rep: Reputation: 30
Descriptive and program related.
Even if I'm doing it just for fun, because if I ever want to look at that program again I won't have a clue what's happening if they aren't well named.
I try to keep them short, but if I have to I'll use longer ones to remove any ambiguity. ~5 character generally, ~15 for the longer ones.
 
Old 12-22-2003, 07:52 AM   #11
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
I always try to be descriptive where I can, normally i put sections into my code, such as "video_codec_check" so it implies what it is (a check box), what it is related to (a bitrate) and what area it is for (video).

Not variables, but I do have a nasty habit of leaving in warnings:
Code:
warn "arse";
was left in a release version of my acidrip package.... clever stuff!
 
Old 12-22-2003, 08:01 AM   #12
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
I read this because it seemed like a rehash of the recent Computing thing - silly folder/directory names. Such as b:\have, c:\itoldyouso, etc etc.

Acid's post make me laugh - I would love to see the face of the user who received that error message.
 
Old 12-22-2003, 10:12 AM   #13
conceptx
Member
 
Registered: Dec 2003
Distribution: Slackware 10, Windows XP Pro
Posts: 33

Rep: Reputation: 15
Thumbs up As long as I can follow

I hardly program but when I do, I don't care much about my variables as long I can figure out wat I am doing and be able to follow back...
maybe that is to why I never get far...
I think I should give more attention to the variable ...
Good post

Ta
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
User Preferences: Use HTML code instead of vB code? (vB code is overrated) stefanlasiewski LQ Suggestions & Feedback 5 07-26-2005 01:37 AM
Logical device names and instant names Gins Linux - General 8 11-30-2004 08:17 PM
SAMBA: display of share names is OK but files names are wrong superandrzej Linux - Software 5 02-02-2004 09:14 AM
Variable names that include variables.... mychl Programming 7 09-24-2003 07:13 AM
Perl question re arrays/variable names Jon- Linux - Software 1 09-19-2003 10:29 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration