Skip to main content
GameDev.net gamedev.net
🔒 Locked

descriptive names?

Started by kvh Jun 21, 2001 at 10:53 AM 10 replies 1.9k views
Original Post
kvh
kvh
the post 'do you comment?' reminded me of this site i found when i was learning some WinSock, www.vijaymukhi.com just thought i'd share it with the rest of the world there's some interesting articles on it, but here's a random extract for the 'i-don't-need-to-comment-cause-i-can-read-code-like-i-read-english' guys:
    
#include <windows.h>
#include<stdio.h>
WNDCLASS a;
long _stdcall zzz();
HWND b;
MSG c;
HDC h;
_stdcall WinMain(HINSTANCE i, HINSTANCE j, char *k, int l)
{
	a.hInstance = i;
	a.lpszClassName = "Hi" ;
	a.lpfnWndProc = zzz;
	a.hbrBackground = GetStockObject(WHITE_BRUSH);
	a.hCursor = LoadCursor(0,IDC_CROSS);
	RegisterClass(&a);
b=CreateWindow("Hi","Bye",WS_OVERLAPPEDWINDOW,1,100,200,300,0,0,i,0); 
	ShowWindow(b,1);
	while(GetMessage(&c,0,0,0))
	DispatchMessage(&c);
}
long _stdcall zzz(UINT w, UINT x, UINT y, long z)
{
	if (x = = WM_LBUTTONDOWN)
	{
		h = GetDC(w);
		LineTo(h,LOWORD(z),HIWORD(z));
		LineTo(h,LOWORD(z),HIWORD(z));
		ReleaseDC(w,h);
	}
	if (x = = WM_DESTROY)
		PostQuitMessage(0);
	return DefWindowProc(w,x,y,z);
}
  
this is part of a tutorial and not some obfuscated c contest, i did not change the formatting in any way, frightening isn't it? looks like he even writes books on Java, C#,... there's even some kind of methodology he uses, variables get 1 letter, functions get 3, all in alphabetical order, simple, but effective hmm, just hope i never get to work with this guy Edited by - kvh on June 21, 2001 11:56:05 AM
Sandman
Sandman
That code is disgusting. Not just the hideous naming scheme for the varibles and functions, but the fact that he likes to make them all global as well. This guy should not be allowed to write tutorials.
Beer Hunter
Beer Hunter
I can read that just fine, thankyou. Not that that''s even relavent to the commenting debate; that''s an example of a lack of descriptive variable names. Have you been smoking something?
Sandman
Sandman
Sure - you can figure that out no problem because it is small. Look at a 5000 line app written in that style and then tell me you have no problems reading it.
Beer Hunter
Beer Hunter
Let''s take a 5000 line version of that, with or without comments. In both cases, it is unreadable unless you''re Carmack (probably the one who wrote the awful mess in the first place ). Descriptive variable names are important.
Kylotan
Kylotan
Especially when as part of a tutorial!
Darkor
Darkor
You can''t blame for trying not to wear out his keyboard...
Beer Hunter
Beer Hunter
Here''s a thought.

"If duplicator duplicates a duplicated duplicator, which was duplicated by a duplicator which now duplicates the duplicated duplicated duplicator into such a position that it duplicates an object, then which duplicator is now in position to duplicate the duplicated object?"

Badly written code is hard to understand. But so is badly written english. And putting footnotes in that sentence isn''t going to help people understand it.

I say, write your code to be as readable as you can. Write in comments to describe the general purpose of a function or a large loop if it''s not already obvious. Just don''t overdo it.
kvh
kvh
ok, you''re right, just forget about the ''i-don''t-need-to-comment-cause-i-can-read-code-like-i-read-english'' part

but i''m sure you understand that that was not the message i was trying to get across, after all, i named the post ''descriptive names?''
Beer Hunter
Beer Hunter
Of course, descriptive variable names are very important. If you referred to the characters in a novel only by their initials, never mentioning their full name, people would have great difficulty.
GayleSaver
GayleSaver
I would venture to presume this programmer writes mathematical functions. Unfortunately, defining mathematical relationships is only a small fraction (however important) of the big picture of programming.
VK

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.