Click here to Skip to main content
15,892,005 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionhow to draw table? Pin
Ali Tavakol14-Jan-06 21:13
Ali Tavakol14-Jan-06 21:13 
AnswerRe: how to draw table? Pin
includeh1015-Jan-06 3:54
includeh1015-Jan-06 3:54 
GeneralRe: how to draw table? Pin
Ali Tavakol15-Jan-06 20:14
Ali Tavakol15-Jan-06 20:14 
Questionvariable, a simple suggestion to C/C++ beginner Pin
includeh1014-Jan-06 17:13
includeh1014-Jan-06 17:13 
AnswerRe: variable, a simple suggestion to C/C++ beginner Pin
El Corazon14-Jan-06 17:49
El Corazon14-Jan-06 17:49 
GeneralRe: variable, a simple suggestion to C/C++ beginner Pin
Stephen Hewitt14-Jan-06 18:03
Stephen Hewitt14-Jan-06 18:03 
GeneralRe: variable, a simple suggestion to C/C++ beginner Pin
El Corazon14-Jan-06 18:39
El Corazon14-Jan-06 18:39 
GeneralRe: variable, a simple suggestion to C/C++ beginner Pin
Shraddhan22-Jan-06 23:34
Shraddhan22-Jan-06 23:34 
I totally agree that some people go overboard with Hungarian notation, presumably in the belief that it will make their code easier to understand.

Me, I have four rules: a pointer variable always starts with p, and a class member variable always starts with m_ and boolean variables always start with b (unless they are called ok or failed). Finally all (of the very few) global variables start with a g_ to highlight that they are global. (I once came across some code, perhaps 200 lines, where the 'programmer' (or idiot, more likely) had defined a global variable called i presumably to save having to define it in every function!)

The first rule certainly helps save confusion, like, Is what I am passing to this function a pointer or a reference? The second rule's benefit comes largely from the fact that with complicated code it is easy to run out of variable names. By sticking a tag in front of a load of the variables, I create room for more. The g_ and m_ prefixes certainly help me stop worrying how the variable got its value.

As for putting an i in front to show that the value is an integer, this is a waste of time at best. And I don't see the point in adding a prefix to strings to indicate that they are null terminated. How many strings are NOT null terminated? Besides, suppose I decide to define

CString Name;
and later in the interests of speed decide to redefine as
char Name[100];

Should I rename Name as psName to show that it is now a pointer to a string? Or call it sName to show that it is an array which works as a string? No, just call it Name, capitalised here because it is an important variable, as distinct from name which is just some temporary name used very locally, a throw-away version.

A name should describe the purpose or algorithmic behavior, not the implementation. The IDE will tell me about implementation. As a programmer looking at ancient code I wrote last month, I want to get an idea of what the code is meant to be doing, what its purpose is, and I do not want to be distracted by irrelevant low level details.

Shraddhan

If you want my advice, contact my secretary for a quotation first.
Questionstructure representing file Pin
John Simon14-Jan-06 14:50
John Simon14-Jan-06 14:50 
AnswerRe: structure representing file Pin
El Corazon14-Jan-06 15:04
El Corazon14-Jan-06 15:04 
QuestionHard maths problem Pin
Christian Graus14-Jan-06 12:41
protectorChristian Graus14-Jan-06 12:41 
AnswerRe: Hard maths problem Pin
Sean Cundiff14-Jan-06 14:25
Sean Cundiff14-Jan-06 14:25 
GeneralRe: Hard maths problem Pin
Christian Graus14-Jan-06 19:56
protectorChristian Graus14-Jan-06 19:56 
AnswerRe: Hard maths problem Pin
Stephen Hewitt14-Jan-06 14:35
Stephen Hewitt14-Jan-06 14:35 
GeneralRe: Hard maths problem Pin
Christian Graus14-Jan-06 19:52
protectorChristian Graus14-Jan-06 19:52 
AnswerRe: Hard maths problem Pin
Michael A. Barnhart14-Jan-06 14:36
Michael A. Barnhart14-Jan-06 14:36 
AnswerRe: Hard maths problem Pin
El Corazon14-Jan-06 14:41
El Corazon14-Jan-06 14:41 
GeneralRe: Hard maths problem Pin
Christian Graus14-Jan-06 20:05
protectorChristian Graus14-Jan-06 20:05 
Questioni need TIC TAC TOE source vc++ Pin
peyman1361814-Jan-06 10:23
peyman1361814-Jan-06 10:23 
AnswerRe: i need TIC TAC TOE source vc++ Pin
Christian Graus14-Jan-06 12:38
protectorChristian Graus14-Jan-06 12:38 
QuestionAccessing Video Files Pin
AJ12314-Jan-06 9:15
AJ12314-Jan-06 9:15 
AnswerRe: Accessing Video Files Pin
Chris Losinger14-Jan-06 9:45
professionalChris Losinger14-Jan-06 9:45 
Questionloading and displaying images Pin
Fatima Tuz Zahra13-Jan-06 19:37
Fatima Tuz Zahra13-Jan-06 19:37 
AnswerRe: loading and displaying images Pin
zubair_ahmed13-Jan-06 20:06
zubair_ahmed13-Jan-06 20:06 
GeneralRe: loading and displaying images Pin
Fatima Tuz Zahra13-Jan-06 20:25
Fatima Tuz Zahra13-Jan-06 20:25 

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.