2 ms·
Something a lot of people seem to forget is that classes are basically the combination of data and functions into a single type dependent namespace. In OOP you
by imtringued 6y ago
Something a lot of people seem to forget is that classes are basically the combination of data and functions into a single type dependent namespace.
In OOP you can have multiple functions that are called "save" and they are primarily distinguished by their type. If you define a static function in Java you call it by invoking its namespace:
MyThing.somefunction(myThing, args)
Alternatively your function is bound to an instance of an object. Then the save function is chosen based on the type of the variable you are calling the function on.
Compare this to Haskell records. Field names are not defined inside a type dependent namespace and therefore you cannot reuse field names in a second record. If I remember type classes correctly they allow you to define implementations sharing the same function name, but they don't allow you to have multiple type classes define a function with the same name so they do not offer type dependent namespaces either.
OOP tends to make organization easier because of this namespacing feature. It probably has led to "over-organized" codebases though. Too much of a good thing can also backfire.
- tome 6y ago> you cannot reuse field names in a second record Sure you can, it just has to be defined in a separate module (because Haskell namespaces correspond directly to modules). It's still annoying that types don't introduce a separate namespace but it is merely annoying.