Click here to Skip to main content
15,914,481 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: VC++ Intelligent Editor Pin
Neville Franks20-Apr-00 14:59
Neville Franks20-Apr-00 14:59 
GeneralRe: VC++ Intelligent Editor Pin
Mike Dunn21-Apr-00 5:32
Mike Dunn21-Apr-00 5:32 
GeneralRe: VC++ Intelligent Editor Pin
wwwaaattt21-Apr-00 7:08
wwwaaattt21-Apr-00 7:08 
QuestionWhat is the accepted naming convention of the controls? Pin
Vintage19-Apr-00 16:49
Vintage19-Apr-00 16:49 
AnswerRe: What is the accepted naming convention of the controls? Pin
Mike Dunn19-Apr-00 19:13
Mike Dunn19-Apr-00 19:13 
AnswerRe: What is the accepted naming convention of the controls? Pin
Member 168320-Apr-00 9:32
Member 168320-Apr-00 9:32 
AnswerRe: What is the accepted naming convention of the controls? Pin
Bill Heffner22-Apr-00 7:45
sussBill Heffner22-Apr-00 7:45 
AnswerRe: What is the accepted naming convention of the controls? Pin
J Cardinal27-Apr-00 11:46
sussJ Cardinal27-Apr-00 11:46 
The importance of a naming convention is directly proportionate to two things:

A) the amount of code you write and need to maintain/understand at a later date.

B) the number of people involved in A.

I program by myself for my own company, I can easily write a thousand lines of code in a day if I'm really humming. It's absolutely critical to me that I use a naming convention. On the other hand if I'm writing a little one shot utility that has maybe 10 variables in it I might just call them all x or y or something because I just don't care. It's hard to misplace a couple of variables in a one function dialog box.

On the other hand for any of my commercial work there is a distinct possibility that down the road if I am successful I just might be hiring someone else to work on that same code. If it's difficult for them to understand I'm going to end up paying them a lot more so it makes sense if your cheap as well. Smile | :)

Personally I do it like this:

m_ prefixes any variable thats a member of a class and visible anywhere in that class (declared in the header not within a function itself).

m_p denotes a member variable that is a pointer.

ed in front of edit box names
btn in front of button names
ck in front of checkboxe names
dt in front of date/timepicker control names
lbl in front of static label names
cb in front of combo box names
rs for recordset names
b for a bool
n for an int
f for a float
str for a CString
etc

So for example I might have: m_btnExit, m_edSalary, m_dtStartDate, m_bIsEditing, m_pstrPassedString etc.

I know at a glance what they are, what they are for and where they are declared (their scope).

And most importantly of all use the EXACT same name everywhere on a large project or you will find yourself squinting at code and zoning out late at night. It's amazing how much time careful naming will save when you have a big job to do and your tired.

I have wasted lots of time when I have done somthing silly like called a dialog resource edit box "IDC_DATE" and then called the variable "m_edStart" or something equally unrelated.

For example I have a hypothetical edit box that is used to enter a first name, I would name it along these lines

IDC_FIRSTNAME for the resource, m_edFirstName for the CEdit control variable.

I don't recommend calling everything a window because thats kind of obvious and doesn't help much when you have a lot to do. It doesn't really matter how you do it, but whatever you choose to do stick with it. If your going to apply for work anywhere programming for a larger company, you should probably find the most popular hungarian naming convention and learn that because it seems to me it might just be one of those silly things a recruitment person might use to weed out prospects.

Just my 2 cents worth.
GeneralADMIN: Forum usage Pin
Chris Maunder19-Apr-00 19:29
cofounderChris Maunder19-Apr-00 19:29 
GeneralException handling Pin
Member 432119-Apr-00 6:13
Member 432119-Apr-00 6:13 
QuestionHow do I to change CMDIChildWnd's client area? Pin
Member 453918-Apr-00 21:30
Member 453918-Apr-00 21:30 
AnswerRe: How do I to change CMDIChildWnd's client area? Pin
Cristi Posea19-Apr-00 0:46
Cristi Posea19-Apr-00 0:46 
GeneralImage Display Pin
arshadwkhan18-Apr-00 19:40
arshadwkhan18-Apr-00 19:40 
GeneralRe: Image Display Pin
Jeremy Davis20-Apr-00 3:03
Jeremy Davis20-Apr-00 3:03 
Generaltemplate function in DLL Pin
0x0000000018-Apr-00 6:26
0x0000000018-Apr-00 6:26 
GeneralRe: template function in DLL Pin
1111119-Apr-00 1:39
1111119-Apr-00 1:39 
Generalcompositing two HBITMAPs Pin
Michael S. Scherotter17-Apr-00 9:15
Michael S. Scherotter17-Apr-00 9:15 
GeneralRe: compositing two HBITMAPs Pin
Cristi Posea19-Apr-00 9:35
Cristi Posea19-Apr-00 9:35 
QuestionHow can I make the "__stdcall" function to be local? Pin
jame17-Apr-00 8:02
jame17-Apr-00 8:02 
AnswerRe: How can I make the Pin
Member 147418-Apr-00 13:38
Member 147418-Apr-00 13:38 
Generalundo operation Pin
Member 432117-Apr-00 5:35
Member 432117-Apr-00 5:35 
GeneralRe: undo operation Pin
Chris Maunder18-Apr-00 1:27
cofounderChris Maunder18-Apr-00 1:27 
GeneralIWebBrowser2 Pin
C. Shawn Bowlin17-Apr-00 5:11
sussC. Shawn Bowlin17-Apr-00 5:11 
GeneralRe: IWebBrowser2 Pin
Arvind2318-Apr-00 1:54
Arvind2318-Apr-00 1:54 
GeneralRe: IWebBrowser2 Pin
C. Shawn Bowlin18-Apr-00 4:35
sussC. Shawn Bowlin18-Apr-00 4:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.