|
aritosteles wrote:
Plus the execution flow should appear to you at a glance.
Agree. I think both styles are acceptable if the nesting level is not too great. If it takes more than two "if's" then the second aproach is more readable. But for two or less levels the first approach is good in the sense that it leave a single exit point of the function.
|
|
|
|
|
Microsoft should better optimize their VS IDE (+ MSDN)!!!
I love the look and feel, but always have the feeling that with old-school C/C++ it could have been 1000+ times faster including no memory leaks at all (keep your IDE open and watch the memory consumption time by time . This is called GC and failed like the Java GC approach. Saddly...).
And MS coding style sux partwise. Take e.g. the naming conventions for callbacks:
- Good example
WNDENUMPROC - Bad example
LPTHREAD_START_ROUTINE
Never understood this. I asume, the MS developer was working late on the CreateThread function .
Good coding style is always important, because after hacking an hour on 20 lines of code you sometimes produce such a mess, that the next day you can start all over again (at least this happens to me sometimes).
Game programmers: forget everything I've said, code fast and slim please. My PC runs only 380 Mhz .
|
|
|
|
|
By MS is the problem that programmers from all over the world code together and sometimes there seems to be a clash of cultures.
I feel that people with very different skills and experience work on code.
|
|
|
|
|
Yeah, but somehow I have the feeling that MS USA writes 99.9% of the code and all other locations translate the stuff. Never saw a MSJ/MSDN article from a german MS developer.
Und hey, Ihr baut die beste ISDN Hardware dies gibt! Macht weiter so!
|
|
|
|
|
Colin Leitner wrote:
Good example
WNDENUMPROC
Bad example
LPTHREAD_START_ROUTINE
I think different
Bad example
WNDENUMPROC
Good example
LPTHREAD_START_ROUTINE
Do you like variables with a 1 - 2 symbols? like int i, ab, ac, aw ...?
All my variables , pointers and others have a strictly system.
And I can get the information from a "first look".
like a variable mp_dwordWasRead;
this is a Pointer to the class Member of DWORD size.
Pavel Sokolov,
CEZEO software,
LanTalk Network,
http://www.cezeo.com
http://www.lantalk.net
|
|
|
|
|
For the last 4 years I had an almost similar system, but with a little better defined system:
PIXELFORMATDESCRIPTOR * pfd_ipPixelFormat;
First a 1 - 3 character id, that gives a conclusion about the type of the var then a '_' and some kind of flags internal ('i'), temporary ('t'), pointer ('p'), array ('a'), unsigned ('u').
Now this can result in some strange names .
unsigned long * lng_tuapCount[4];
A unsigned long pointer array used to count something.
*lol*
Now I use simple and clear names without any pre and postfixes. It makes your code much nicer!
unsigned long * count[4];
Pavel Sokolov wrote:
I think different
That's OK, but MS should use a well defined system and don't let any programer type like he want's to. This happened with the CreateProcess, wich is BAD coding style. A THREADPROC would have been much more obvious and shorter to type (for casting).
Oops I forgot the global 'g', const 'c' and the volatile 'v' flags .
volatile const unsigned long * lng_vgcuapCount[4] = {0, 0, 0, 0};
(Probably not valid... I never use the volatile keyword and I'm no fan of const values)
|
|
|
|
|
Colin Leitner wrote:
unsigned long * lng_tuapCount[4];
A unsigned long pointer array used to count something.
*lol*
Now I use simple and clear names without any pre and postfixes. It makes your code much nicer!
unsigned long * count[4];
I can't use it, my current project have a 150 classes and unnamed variables is hell for me
Pavel Sokolov,
CEZEO software,
LanTalk Network,
http://www.cezeo.com
http://www.lantalk.net
|
|
|
|
|
Pavel Sokolov wrote:
I can't use it, my current project have a 150 classes and unnamed variables is hell for me
It sounds like your code needs to be cleaned up (simplified) if you have 150 classes!
|
|
|
|
|
Anonymous wrote:
It sounds like your code needs to be cleaned up (simplified) if you have 150 classes!
This is a minimum...
Pavel Sokolov,
CEZEO software,
LanTalk Network,
http://www.cezeo.com
http://www.lantalk.net
|
|
|
|
|
ps.
VS.NET have a poor interface with a poor speed ( pIII 450/ 768mb RAM ).
and I downgraded to VC6.0
Pavel Sokolov,
CEZEO software,
LanTalk Network,
http://www.cezeo.com
http://www.lantalk.net
|
|
|
|
|
Ok, but although it's a bit slow my cranky old f*ck (that's my PC) still runs VS.NET quite good. Viewing the DHTML reference in the MSDN is a real pain in the ass!
|
|
|
|
|
You do not buy new compiler, cause it is faster, but cause it is better (more new functionality, new classes, easier work - I don't say that it is all there, in vc7). If You want fast compiler, get Borland C++ 3.1 for DOS - heh - it is really fast for today.
|
|
|
|
|
where new classes? do you know vc7 ? if I want to add new class in vc7 I should wait 5 -7 seconds before html dialog is loaded. I have pIII-450 with 768 mb of RAM, I think this is not an old computer.
Pavel Sokolov,
CEZEO software,
LanTalk Network,
http://www.cezeo.com
http://www.lantalk.net
|
|
|
|
|
Pavel Sokolov wrote:
if I want to add new class in vc7 I should wait 5 -7 seconds before html dialog is loaded. I have pIII-450 with 768 mb of RAM, I think this is not an old computer.
I have used VC7 a lot on my old computer, a PIII-600 with 512 MB Ram, and it worked great. Didn't have to wait much for those dialogs.
A lot of it have to do with your disks though...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
oh c'mon! you "programmers" can afford $1,000+ for VS.NET, but can't spend the same amount on a decent computer? sad sad thing.
|
|
|
|
|
First of all, I've only spent aprox. $350 on a VS.NET upgrade.
I also have a great almost new computer (Dual 1800+), but we were talking about the speed on low/middle range computers...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Ellery,
Some of the people replying to this discussion thread are not professional programmers. Rather, they are students learning how to use the latest and greatest tools. Unfortunately, this means that they never paid for VS.NET. I'm sure you can draw your own conclusions from that statement...
From this point of view, they are paying exactly the same amount for the hardware as the software.
--
Paul
"I drank... WHAT?"
|
|
|
|
|
Ellery Familia wrote:
oh c'mon! you "programmers" can afford $1,000+ for VS.NET, but can't spend the same amount on a decent computer? sad sad thing.
I suspect some of them may have bought on a "promotion" and paid only $2 each CD.
Concussus surgo.
When struck I rise.
|
|
|
|
|
I would think a laptop with a 1GHz Duron (256MB RAM) counts as a "decent computer"...and VS.NET runs like a fly in treacle on it.
IMHO There's no denying that VS.NET requires a lot more power than VS6...though even VS6 is pretty slow on large projects.
Andy Metcalfe - Sonardyne International Ltd
Trouble with resource IDs? Try the Resource ID Organiser Add-In for Visual C++
"I would be careful in separating your wierdness, a good quirky weirdness, from the disturbed wierdness of people who take pleasure from PVC sheep with fruit repositories."
- Paul Watson
|
|
|
|
|
And if you change the DWORD to a WORD, do you diligently search and replace all references to the variable name with the corrected name? Maybe you do, but I bet a lot of other people don't. Plus, why code the storage method as part of the name? Isn't this why we have getter/setter methods, so we don't need to concern ourselves with internal implementation, and therefore don't care about the storage mechanism?
Marc
|
|
|
|
|
I'm happy with my notation
Pavel Sokolov,
CEZEO software,
LanTalk Network,
http://www.cezeo.com
http://www.lantalk.net
|
|
|
|
|
Marc Clifton wrote:
And if you change the DWORD to a WORD, do you diligently search and replace all references to the variable name with the corrected name? Maybe you do, but I bet a lot of other people don't.
Actually, I do that, and have no problem with it. If I'm changing the size of something, it's not a bad idea to go look at all usages of it as part of the change; it usually only takes a few minutes. Might as well change them whild looking.
Marc Clifton wrote:
Isn't this why we have getter/setter methods, so we don't need to concern ourselves with internal implementation, and therefore don't care about the storage mechanism?
As nice as that sounds, frequently we do care about the storage mechanism. For example, in communicating with external devices - whether they be musical instruments as in my work, or files, whatever - the size of storage is frequently hard-coded and must be respected. Sometimes data must be passed through a pipe of fixed size.. in which case data may be truncated and precision or sign lost.
Here's another example: I work in a typical mixed environment, with character strings represent in various APIs as either char*, CString, or STL string. Frequently I have to deal with two or even all three types in the same chunk of code, all referring to the same text. In this case specific prefixes are very helpful.
|
|
|
|
|
In Pavel's defense, I too prepend variable names with their type. I find it generally helps the readability of the code. And yes - if I change a variable type, I do change the variable name accordingly - otherwise doing it in the first place is useless!!
You talk about having get/set functions for data hiding, but what about within the class itself?
I think after using it for a while you can really benefit. My colleague recently named some variables sBlah (CString) instead of saBlah (CStringArray) and it caused no end of confusion!
-Paul
|
|
|
|
|
PaulMdx wrote:
You talk about having get/set functions for data hiding, but what about within the class itself?
I use a strongly C++, object oriented notation with a data hiding and others cool stuff, inside the class too.
Pavel Sokolov,
CEZEO software,
LanTalk Network,
http://www.cezeo.com
http://www.lantalk.net
|
|
|
|
|