netopyr / reduxfx

Functional Reactive Programming (FRP) for JavaFX
Apache License 2.0
112 stars 11 forks source link

ActionType vs. the class of the action #1

Closed Petikoch closed 8 years ago

Petikoch commented 8 years ago

Hello @netopyr ,

thanks for creating reduxfx, it looks really nice. @lestard told me yesterday about it...

I just looked into the documentation. Isn't the ActionType redundant to the action class? Since an action could carry some data, an updater implementation would anyway need to cast the action to the specific action class to access the "action data". Therefor an updater implementation could implement "the switch" using instanceof (with if/else if/else... or of course some fancy javaslang pattern matching) without using the ActionType.

Would do you think?

Best regards, Peti

netopyr commented 8 years ago

Hi Peti,

yes, the ActionType is redundant. I added it, because I prefer a switch-case instead of a long list of if-elses. Also instanceof has a rather bad reputation when it comes to performance, I wonder if one would notice when doing a lot of them in each iteration. But that is just a theory, the main reason is the switch-case.

I like your idea of using the Javaslang pattern matching. Have not thought about that. In a real application, I would probably go for that, but I think it is too exotic to use it in a simple example.

Cheers, Michael

Petikoch commented 8 years ago

Thanks for your thoughts. Best regards! Peti