Why are global variables bad, in a single threaded, non-os, embedded application

后端 未结 13 1645
既然无缘
既然无缘 2020-12-01 05:20

Most of the objections I see to using global variables make sense since they refer to issues of multiple threads, thread safety, etc.

But in a small, single threaded

13条回答
  •  旧巷少年郎
    2020-12-01 05:43

    Code which uses global variables is harder to maintain. Since the maintainer must find every use of thevariable in the system before she can know precisely what the variable does. Since this slows maintainence it should be avoided as much as possible. That's it `

提交回复
热议问题