Using "prevent execution of method" flags

Posted by tpaksu on Programmers See other posts from Programmers or by tpaksu
Published on 2012-03-26T18:05:54Z Indexed on 2012/03/26 23:38 UTC
Read the original article Hit count: 260

First of all I want to point out my concern with some pseudocode (I think you'll understand better)

Assume you have a global debug flag, or class variable named "debug",

class a :
   var debug = FALSE

and you use it to enable debug methods. There are two types of usage it as I know:

first in a method :

 method a :
      if debug then call method b;

 method b :

second in the method itself:

 method a : 
       call method b;

 method b :
      if not debug exit

And I want to know, is there any File IO or stack pointer wise difference between these two approaches. Which usage is better, safer and why?

© Programmers or respective owner

Related posts about design-patterns

Related posts about variables