4 ms·
When you write a procedure that has to maintain an internal state between calls, changing it into a class makes sense. As for the name, you change the verb (wr
by Dwedit 2y ago
When you write a procedure that has to maintain an internal state between calls, changing it into a class makes sense. As for the name, you change the verb (write) into a noun (writer), and you now have a name for the class.
C# will silently create hidden closure classes for you when you use lambdas or yield.
- arendjr 2y agoJust know that if you do this, you’re injecting statefulness in the center of wherever it was this procedure was being used. If your entire system already has statefulness everywhere, nobody will bet an eye. But if you want to have any chance at creating a functional core or island, it’s the opposite of what you should be doing.
- alex-robbins 2y agoWhen you write a procedure that has to maintain an internal state between calls, stopping what you're doing and switching to functional programming makes sense.