What is namespace pollution?

前端 未结 2 1553
甜味超标
甜味超标 2020-12-01 14:55

What does the term \'namespace pollution\' mean and why would making a method static help to prevent it?

This question seems to be similar but relates specifically t

2条回答
  •  既然无缘
    2020-12-01 15:49

    Namespace pollution is a lot like pollution in general. It means that something is misplaced. In programming that means that code that should really live in separate namespaces is added to a common namespace (in some cases the global namespace). This can happen with both static and non static code, so I don't really see a scenario where static helps prevent namespace pollution.

    Basically, namespaces' main function is to categorize code, and both static and non static code must be defined in a namespace somewhere.

提交回复
热议问题