Re:Dart 3.1 and a retrospective on functional style programm...
by layer8 on Thursday August 17, 2023 @05:58AM
(#37159431)
That means having to code the dispatch manually that OO languages do automatically. Itβs kind of the point of OO languages to not have to do that manually, and to have the subtype-specific functions be explicitly associated with each other, and not just implicitly by how they are used.
[ Parent
| on HN ]
Re:Dart 3.1 and a retrospective on functional style programm...
by zogrodea on Thursday August 17, 2023 @06:26AM
(#37159593)
That's true. I didn't describe very well what I am doing in one of my projects, but it is like this: https://justpaste.it/dajf5 .
I can't say I've had any issues with code like this (omitted a lot of details here but hoping it's still somewhat readable/understandable). You don't need everything to have its own type. Introduce more types and match on them if that type information is useful, or else write a function that fits in an existing type. Perhaps OOP is better for the approach I mentioned. What do you think and why?