 |
Server Help Community forums for Subgame, ASSS, and bots
|
Author |
Message |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Mon Sep 06, 2004 7:06 pm Post subject: |
 |
|
|
|
If your debugger can't step into any line of source code, then it's not a real debugger. And if you can't handle stepping into an extra level of function calls in ASM, then don't program.  _________________ 4,691 irradiated haggis! |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
|
Back to top |
|
 |
50% Packetloss Server Help Squatter

Age:40 Gender: Joined: Sep 09 2003 Posts: 561 Location: Santa Clarita, California Offline
|
Posted: Mon Sep 06, 2004 10:42 pm Post subject: |
 |
|
|
|
You break; out of the switch. Never have a return except at the end of the function. |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Tue Sep 07, 2004 12:24 am Post subject: |
 |
|
|
|
BOOL DialogProc (...)
{
BOOL ret = FALSE;
...
switch (msg)
{
...
case WM_INITDIALOG:
for (i = 0; i < NUM_MSGS; i++)
SendDlgItemMessage(page, IDC_M_SEL, CB_ADDSTRING, 0, (LPARAM)message_names[i]);
for (i = 0; i < NUM_CINEM; i++)
SendDlgItemMessage(page, IDC_M_SELC, CB_ADDSTRING, 0, (LPARAM)cinem_names[i]);
ret = TRUE;
break;
...
}
return (ret);
} |
Glad to see you are using raw Win32.
Almost all messages you return FALSE if you handle them, so set return once at top, and only change in special cases. |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Tue Sep 07, 2004 12:56 am Post subject: |
 |
|
|
|
It's still ugly though... and it's not like having a return there is a safety hazard in any way. I just don't think we all should be so strict about it.
On a side note, I #included the old iostream headers today in Dev-C++ and it complained at me for not using those darned template classes. Like I really need all that code bloating the size of my executable? Basically, I say all us likers of clean code (even if we do disagree on returns) should stage a coup d'etat against ANSI, MS, and Mr. Plauger and rule the world in its place. Or maybe I'm just really too tired to be talking. |
|
Back to top |
|
 |
Mine GO BOOM Hunch Hunch What What

Age:41 Gender: Joined: Aug 01 2002 Posts: 3615 Location: Las Vegas Offline
|
Posted: Tue Sep 07, 2004 1:03 am Post subject: |
 |
|
|
|
Cyan~Fire wrote: | Like I really need all that code bloating the size of my executable? |
I'm sure nothing you are making right now even comes close to the efficiency of making a program that will need real-time speed. And the size of the executable is negligable for what you are working with.
Cleanliness isn't always the best. Whats important, is that someone else ten years from now is able to look over your source code, understand most of what is there without reading any outside information (ie: no manual, only source comments), and be able to modify it or convert it to what he needs. If that means making your source a bit ugly at a glance, so that someone can determine what you are doing, thats a good trade off. |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Tue Sep 07, 2004 4:39 am Post subject: |
 |
|
|
|
Cyan~Fire wrote: | It's still ugly though... and it's not like having a return there is a safety hazard in any way. I just don't think we all should be so strict about it.
On a side note, I #included the old iostream headers today in Dev-C++ and it complained at me for not using those darned template classes. Like I really need all that code bloating the size of my executable? Basically, I say all us likers of clean code (even if we do disagree on returns) should stage a coup d'etat against ANSI, MS, and Mr. Plauger and rule the world in its place. Or maybe I'm just really too tired to be talking. |
If you look at each function and decide "this one doesn't need to be so strict" and "this one does", then you fall into the trap of making a mess as you edit, design, maintain, and evolve. You will often find that a simple function where you didn't care suddenly got more complex. But you don't have the time right now to fix it, so it gets big and buggy. What would have taken 5 seconds to do right the first time now takes you a week to debug. I've seen it over and over: malloc/free, open/close, create/destroy, new/delete, uninitialized variables, things that make your app a system hog but not crash, etc.
I don't know your experience level, your career, or how old you are, but I think you will find yourself becoming more strict as you go after betting burned or watching it happen in other people's code in the same project you are one (when you have to work all weekend to find the function they didn't care to design right). |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Tue Sep 07, 2004 10:34 am Post subject: |
 |
|
|
|
MGB wrote: | I'm sure nothing you are making right now even comes close to the efficiency of making a program that will need real-time speed. And the size of the executable is negligable for what you are working with. |
I like to keep my executables small. There is also a C runtime library I use to do so. If it's going to get mad at me about using that CRT, I'm going to get mad at it. The whole effeciency/size thing is not that I think it will make a difference in the program, it's just that it could always be better so I will always be trying to make it better.
Ekted wrote: | If you look at each function and decide "this one doesn't need to be so strict" and "this one does", then you fall into the trap of making a mess as you edit, design, maintain, and evolve. |
Except that I never use mid-function returns unless it's a function that's never going to do anything that requires cleanup. And in my WindowProcs, I just use break if it's going to return 0 and return something else if necessary. If the 'something else' ends up complex enough to need cleanup, I stick it in a handler anyway.
Ekted wrote: | I don't know your experience level, your career, or how old you are, but I think you will find yourself becoming more strict as you go after betting burned or watching it happen in other people's code in the same project you are one (when you have to work all weekend to find the function they didn't care to design right). |
My programming is purely hobbyist right now, but AFAIK I'll end up in a corporate environment. If I have to deal with others' messy code, I'm going to have to worry about a heck of a lot more than returns, I believe. However, if my current plan of things works out, I'm going to be co-founding a video game company... but that's probably just pretentions. |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Tue Sep 07, 2004 2:02 pm Post subject: |
 |
|
|
|
Quote: | However, if my current plan of things works out, I'm going to be co-founding a video game company... but that's probably just pretentions. |
I'll work for you.  |
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Tue Sep 07, 2004 3:39 pm Post subject: |
 |
|
|
|
rotfl... _________________ Performance is often the art of cheating carefully. - James Gosling |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Tue Sep 07, 2004 7:50 pm Post subject: |
 |
|
|
|
More like I'll work for you, since I'm sure you wouldn't ever want me controlling what you code  |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Tue Sep 07, 2004 9:33 pm Post subject: |
 |
|
|
|
Cyan~Fire wrote: | More like I'll work for you, since I'm sure you wouldn't ever want me controlling what you code  |
No one I've ever worked for controlled my code. You hire really good people, pay them whatever they want, and let them do whatever they want. That's how you get results. Hiring people that will work for 50K, putting them in rows of cubicles, managing them with unqualified people (ie non-techies), making them work 9-5, go to meetings, fill out time sheets, dress codes, or expecting everyone to conform to some arbitrary system is a sure-fire way to make sure that progress and morale are crap.
3 people in the first situation can out-perform 30 in the second. |
|
Back to top |
|
 |
Smong Server Help Squatter

Joined: 1043048991 Posts: 0x91E Offline
|
Posted: Thu Sep 09, 2004 4:35 pm Post subject: |
 |
|
|
|
And if Ek works for Cyan he will never be out of a job constantly cleaning up his code. |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Thu Sep 09, 2004 4:44 pm Post subject: |
 |
|
|
|
Fixing my returns... hahaha. |
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
Software by php BB © php BB Group Server Load: 108 page(s) served in previous 5 minutes.
|