3 ms·
> Binding data and functions together beats operating on global data visible to everything. One of the big wins of OOP is less exposed global data. ... These t
by overgard 8y ago
> Binding data and functions together beats operating on global data visible to everything. One of the big wins of OOP is less exposed global data.
... These things are unrelated. Just write functions that don't operate on global exposed data? You know, like, function arguments.
- layoutIfNeeded 8y ago>You know, like, function arguments. That's a good idea! Although... I wonder if you would get tired of passing around the same piece of data between such functions all the time? Here's a crazy idea: what if we pass the data implicitly to such functions? Like, we could pretend that the data was passed to the function as a hidden argument, and we could call this argument "self" or "this"! :O
- overgard 8y agoOr! You could just pass in a data structure without methods! The problem with global variables is implicit dependencies, and with “this” or “self” you now have slightly scoped implicit dependencies. I say slightly because you still have to worry about base classes. It’s the same problem just more contained.