Click here to Skip to main content
15,888,454 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Just a matter of style.. Pin
David Crow4-Oct-07 10:21
David Crow4-Oct-07 10:21 
GeneralRe: Just a matter of style.. Pin
bigdenny2004-Oct-07 10:38
bigdenny2004-Oct-07 10:38 
GeneralRe: Just a matter of style.. Pin
led mike4-Oct-07 9:42
led mike4-Oct-07 9:42 
GeneralRe: Just a matter of style.. Pin
Mark Salsbery4-Oct-07 9:47
Mark Salsbery4-Oct-07 9:47 
GeneralRe: Just a matter of style.. Pin
bigdenny2004-Oct-07 10:11
bigdenny2004-Oct-07 10:11 
GeneralRe: Just a matter of style.. Pin
Mark Salsbery4-Oct-07 10:22
Mark Salsbery4-Oct-07 10:22 
GeneralRe: Just a matter of style.. [modified] Pin
bigdenny2004-Oct-07 10:39
bigdenny2004-Oct-07 10:39 
GeneralRe: Just a matter of style.. Pin
El Corazon4-Oct-07 10:51
El Corazon4-Oct-07 10:51 
Mark Salsbery wrote:
A problem occurs in changes later - any cleanup of new objects may
need to be done at every exit point. What if you miss one?


I have no manditory rules on this, though I do try to have a single exit point for just those cleanup reasons, I do have multiple exit points for culling determination. For instance checking a sensor for operations:

sensor()
{
if outside range return;
if outside azimuth field of view return;
if outside elevation field of view return;
allocate variables;
process;
cleanup;
return;
}

in this case there are multipe exit points, but the idea is to reduce the processed data before the allocation of process overhead. Therefore the resources are reduced by the previous exit points, and only one exit point has to worry about cleanup. I consider that a single exit point. It could be rewritten as a single exit point:

sensor()
{
if (inside range && inside azimuth && inside elevation)
{
allocate variables;
process;
cleanup;
}
return;
}

but when the list of checks grows significantly inside the if statement it still becomes difficult to read. In the case of the sensor comparisons, there are more checks going on there I can't show, and the list did get too lengthy, so I used the culling paradigm instead. Even in debugging it is easier to follow than a single long if.

_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

GeneralRe: Just a matter of style.. Pin
Mark Salsbery4-Oct-07 11:00
Mark Salsbery4-Oct-07 11:00 
GeneralRe: Just a matter of style.. Pin
El Corazon4-Oct-07 13:34
El Corazon4-Oct-07 13:34 
AnswerRe: Just a matter of style.. Pin
David Crow4-Oct-07 9:21
David Crow4-Oct-07 9:21 
GeneralRe: Just a matter of style.. Pin
bigdenny2004-Oct-07 9:31
bigdenny2004-Oct-07 9:31 
GeneralRe: Just a matter of style.. Pin
David Crow4-Oct-07 9:46
David Crow4-Oct-07 9:46 
AnswerRe: Just a matter of style.. Pin
Michael Dunn4-Oct-07 11:03
sitebuilderMichael Dunn4-Oct-07 11:03 
GeneralRe: Just a matter of style.. Pin
bigdenny2004-Oct-07 11:06
bigdenny2004-Oct-07 11:06 
AnswerRe: Just a matter of style.. Pin
John R. Shaw4-Oct-07 11:28
John R. Shaw4-Oct-07 11:28 
AnswerRe: Just a matter of style.. Pin
DQNOK15-Oct-07 11:27
professionalDQNOK15-Oct-07 11:27 
QuestionGetting the handle of active window in other thread Pin
dudedotnet4-Oct-07 8:07
dudedotnet4-Oct-07 8:07 
AnswerRe: Getting the handle of active window in other thread Pin
Mark Salsbery4-Oct-07 8:47
Mark Salsbery4-Oct-07 8:47 
GeneralRe: Getting the handle of active window in other thread Pin
dudedotnet8-Oct-07 1:38
dudedotnet8-Oct-07 1:38 
QuestionRe: Getting the handle of active window in other thread Pin
Mark Salsbery8-Oct-07 6:47
Mark Salsbery8-Oct-07 6:47 
AnswerRe: Getting the handle of active window in other thread Pin
dudedotnet9-Oct-07 1:38
dudedotnet9-Oct-07 1:38 
GeneralRe: Getting the handle of active window in other thread Pin
Mark Salsbery9-Oct-07 5:52
Mark Salsbery9-Oct-07 5:52 
GeneralRe: Getting the handle of active window in other thread Pin
dudedotnet9-Oct-07 23:55
dudedotnet9-Oct-07 23:55 
QuestionInserting an ActiveX control based TreeView into a CAD program Pin
larsgregersen4-Oct-07 6:03
larsgregersen4-Oct-07 6:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.