Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

kvh

descriptive names?

This topic is 6235 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?''

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!