#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
descriptive names?
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:
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.
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?
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.
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.
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.
"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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement