4 ms·
Easy solution: static class.
by tedmiston 4y ago
Easy solution: static class.
- ehnto 4y agoFor sure, satic classes and functions are what I would use if the language has them.
- ajuc 4y agoCan still have internal state.
- ehnto 4y agoI suppose, but that's if you build it that way. A 'pure' function can also have state if you pull it in through global vars or other functions. Writing stateless code has to be deliberate no matter which method you use.
- tedmiston 4y agoHow can a purely static class have internal state if there's no instantiation of the class or instance variables? Are you referring to variables declared on the class directly? If so, that feels analogous to a function potentially having module-level state variables to me, in Python for instance.