http://blog.ploeh.dk/2018/01/08/software-design-isomorphisms/
- Where can I go to learn more about category theory
unit
in functional languages is isomorphic to void
in OO languages
methods
which take paramaters and use the this
keyword are isomorphic to static methods
and functions
which take the same arguments plus an argument the same as whatever this
was in the method.
You can also close over (closure) whatever this
was and preserve the arity of the function you're calling.
Argument lists, tuples, and objects with fields that represent all the arguments in the latter are all isomorphic.
curry
ing and uncurry
ing create functions that are isomorphic to each other?
I'm not sure the point of this particualr blog post.
object
- data with behavior
closure
- behavior that closes over data
Objects and closures are isomorphic.
Abstract classes define the contract for something that will implement it. That contract can be turned into an interfasce which can then be injected into a component that knows how to compose it.
You've got the inheritance relation B --inherits from--> A such that B.method() calls A.method(), modifies its result, then returns it.
You can acheive the same result by instantiating A inside of B, and calling A.method. You can also pass A to B as a parameter. That's the decorator pattern.