|
<>&
|
|
|
|
|
|
hey it's script kiddie
Normski. - the next bit of code is self modifying ... jmp 0xCODE
|
|
|
|
|
I hate when people leave a junk, commented out code behind while doing their changes. E.g.:
#define FOO_BLANK 0
#define FOO_FNTCDE 1
#define FOO_BRANCHREF 2
#define FOO_CPTYONE 3
#define FOO_EXECCDE 4
#define FOO_TRANTYP 5
#define FOO_CSHID 6
#define FOO_EXTREF 7
#define FOO_TRANID 8
#define FOO_TRANSEQ 9
#define FOO_STATUS 10
Why to remark something just to copy it few lines below and change? Source code is not a history book, it should be clean and version control is for keeping previous versions of the code dammit!
|
|
|
|
|
George wrote:
Why to remark something just to copy it few lines below and change?
On the whole, I'd agree with you, but there are times when this can be useful as a "don't do it this way, we've tried it and it doesn't work" comment. Sometimes people invent and reinvent the same flawed solution, because it appears to be better and/or simpler.
This probably wouldn't apply to your example, of course!
Gavin Greig
|
|
|
|
|
Well, right, but as I understand he means that people commenting unneeded code instead of just deleting that. This especially makes no sence when you use SourceSafe, which holds for you the whole history, lol
The first thing I do when I get such project - going and deleting all comments (I mean code comments of course). I remember someday I got a cpp file from some guy, who was very proud that his project has about 10k lines of code. How much left after removing all commented code you think? 2k LMAO. That was funny
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
Philip Patrick wrote:
The first thing I do when I get such project - going and deleting all comments
Funny, I do it all the time, also for a left out empty lines with no purpose at all and at the same time no separation when it's obviously needed
And it drives me nuts sometimes all the time
Take a look at small example (that one is a classic, all code junkies around me code like that):
struct Foo_struct
{
CString strFooID;
};
#include "ctlfoo.h"
#include "ctlbar.h" Now, note two empty lines at the end of structure definition, and then no separation from the includes? WTF?
It gets even better:
#include "ctlbar.h"
#include "foobar.h"
#include "ToolTip.h"
class CFooBarClass;
#include "..\FooDir\SomeFile.h"
class CThisClass : public CDialog
{
I mean, for heavens sake, my 4 years old kid drawings have more order and make more sense than this...
I am not chasing that thought, I only fix it as I go along in a particular part of the code. Otherwise I would have to sit a month just formatting that code crap...
|
|
|
|
|
LMAO, yeah, saw such code too, agree with you,. it can drive you nuts when you are trying to read and understand what the code does
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
Here's the sad part: note that much of the code crap in there is commented, "Added by ClassView ."
Code "wizards" are both a blessing and a curse: they can make life easier, but you've got to police them.
|
|
|
|
|
UltraJoe wrote:
Here's the sad part: note that much of the code crap in there is commented, "Added by ClassView."
I believe it was actually pushed down by the coder when inserting the struct definition, so it's not the class wizard to blame, or at least not entirely
UltraJoe wrote:
Code "wizards" are both a blessing and a curse: they can make life easier, but you've got to police them.
Yep. What I always hate is when some wizard tries to micro-manage code, changing the unrelated bits of code for some unknown reason. Really makes life hard if you work on the code in concurent way (like when using CVS for example).
|
|
|
|
|
I've seen this practice not so much as a "history book," but rather as a way of saying, "hey, I thought about this, but it's not ready for prime time yet, but I don't want to lose it." In other words, no, it's not part of live code, but it doesn't appear in version control, either.
|
|
|
|
|
I tend to leave commented lines until I get the code to work as I expect and until I'm pretty sure I'm not going to work on that bit of code anymore. Then I delete everything not needed.
Solid, working code should look good. I makes life easier for everyone.
Plus the execution flow should appear to you at a glance. I hate when my partners do the following:
if()
{
if()
{
if()
{
/* long code block here*/
}
else
{
return;
}
}
else
{
return;
}
}
else
return;
when they could just test conditions first and leave code visually clear:
if(!condition)
return;
if(!condition)
return;
if(!condition)
return;
if(!condition)
return;
/*long block code here*/
|
|
|
|
|
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
|
|
|
|