Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 12
    To you a +1, be it a toilet or a commode they reek the same. Nice job pointing out the wolf in sheep's clothing. Commented Jul 13, 2017 at 14:02
  • 1
    +1 for stating that both many parms and global vars are bad. But I want to clarify something. In most languages, primitive parameters are passed by value by default (Java), and in others you can pass them by value explicitly (PL/SQL). In the other hand global primitives are always accessed by reference (so to say). So parameters, at least of primitive types, are always safer than global variables. Although of course having more than two or three parameters is a smell, and having twelve parameters is a huge smell that shoule be refactored. Commented Jul 13, 2017 at 15:49
  • 4
    Absolutely, a global variable IS a hidden parameter. Commented Jul 14, 2017 at 16:44
  • +1 To your point, I've seen MATLAB simulations that rely on global variables to pass data. The result was completely unreadable because it was so hard to tell which variables were parameters to which function. Commented Jul 14, 2017 at 21:00