As I surfed through the vast tubes of the inter-webs I often read about different programming conventions. Most of the time they're the same thing I've heard a thousand times, comment often, don't use magic numbers, etc.. Except for today where I stumbled upon an argument (check out post
here) on why you should really avoid using Boolean values. In particular as parameters, the problem seems to lie with the fact that booleans aren't very descriptive. So for example if I had a routine that looked like the following code and used it in this manner is it obvious what that boolean value means?
Draw("Circle",True)Draw("Circle",False)Instead isn't it a lot clearer to use an enumeration value like the following?
Draw("Circle",ColorMode.Fill)Draw("Circle",ColorMode.Outline)Really this is a matter of preference, but I'll have to admit the latter version is clearer in what the parameter is triggering.
No comments:
Post a Comment