Pure Functions - Pure Methods?
The idea of a 'pure function': There's no contact point to the outside world besides the function's parameters and return value. The thinking looks similar to the idea of 'encapsulation' in OOP: By reducing the ways data goes in and out, you also reduce the number of ways things could go south. Now I'm thinking about a class and its instances. Normally we have some data and a bunch of methods in which we often refer directly to the data, like self._x. In a way, doesn't this again increase the ways bad stuff can happen? Should we also write 'pure methods' in order to prevent class-internal trouble? On the other hand, that will make the parameter lists grow, and to me it feels somewhat strange that an object should pretend not to know its own data. Or is it a matter of size, like we'd go more like m()/self.value when the class is smaller, and more like m(self._x, self._y) when it's bigger? How to draw the line and make the right decision?