Dealing with a static cling in Swift

As programmers we often have to deal with legacy code, usually not written by us, sometimes of bad quality, without unit tests, hard to modify, with high regression risk. One of ubiquitous code smells is so called static cling. It is so frequent because lots of developers “love” static functions, singletons and in fact greatly abuse those patterns.
We do so, because static code seems easier and faster to write, but in a longer run, the code written using those patterns is hard to test, not reentrant, coupled, maintaining global state and is just badly designed.

Read More