LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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


Reply
  Search this Thread
Old 03-03-2013, 02:22 PM   #1
bigbankclub
LQ Newbie
 
Registered: Mar 2013
Posts: 7

Rep: Reputation: Disabled
UPPERCASE or lowercase for Variables?


Looking at internal variables these are in uppercase. Any reason why? Does it matter? If I use $USER vs $user what's the difference? The code still works. Ideally to be uniform, what would be the ideal method?

Last edited by bigbankclub; 03-03-2013 at 05:38 PM. Reason: typo
 
Old 03-03-2013, 04:05 PM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
Hi

$USER is special, holding your username. There is nothing special about $user, you have to assign a value yourself. For readability, we should avoid using variable names in uppercase. They could be "special" or maybe get a special meaning in the future. For example this might surprise you if you don't know about $RANDOM:

Code:
RANDOM=123
echo $RANDOM
 
Old 03-03-2013, 06:59 PM   #3
DiBosco
Member
 
Registered: Nov 2001
Location: Manchester, UK
Distribution: Mageia
Posts: 807

Rep: Reputation: 40
If I understand your question correctly...

...the naming convention is usually that capital letters indicate a #define value.

Some people like to use capitals at the start of words within the variable in the following way:

#define BUFFER_SIZE 200

char SerialDataIn[BUFFER_SIZE];

Others prefer things like this:

char serial_data_in[BUFFER_SIZE];

Qt tends to use:

serialDataIn.
 
  


Reply



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
Change all uppercase to lowercase with vi?? ufmale Linux - Newbie 13 08-07-2018 05:25 AM
UPPERCASE to lowercase command? pk21 Linux - General 4 06-12-2007 10:26 AM
Lowercase to Uppercase stellafrank Linux - Software 2 11-16-2006 05:46 AM
Converting Uppercase to Lowercase AMMullan Linux - Software 6 10-18-2005 07:32 PM
Converting lowercase to uppercase noodle123 Programming 1 05-17-2002 02:12 PM

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

All times are GMT -5. The time now is 09:39 PM.

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