Separation of read/write accessors #5
Replies: 1 comment 1 reply
-
Hey @mindplay-dk Thanks for starting this discussion. You are the second person who has told me this, and I have heard ryan solid also mention that in his experience developers much prefer the new solid style of signal destructuring compared to old style.
TBH I didn't give much consideration to this issue since I just wanted to get something working out of the window that I could start using in production. I'm building @gratico using alfama which now has a decent size codebase, and I would agree alfama has some issues in DX and it's not as polished as solid/react in that respect. But I'll try to improve it starting with this issue. Btw, I do remember reading your comment on haptic about dipole nettyso/haptic#5. That's a style I would like to implement for store cursors when I get time. What do you think about that?
|
Beta Was this translation helpful? Give feedback.
-
Have you given much thought to "conjoined" vs separate read/write accessors?
ChatGPT can sum up the differences nicely:
https://chatgpt.com/share/488d61e1-577b-42bd-a19e-63a81c16dff0
The pros for seperate functions that I like to highlight are:
And the main problem with a single function:
This one is important - skimming over code where read and write operations look very similar requires more mental parsing.
The only real down side (from my perspective) is this:
I don't find this difference is important enough to put up with the ambiguity, but of course YMMV. 😄
Popular frameworks like Solid are kind of setting the tone for this important detail. I was an early adopter of Sinuous - and I loved it, but I now definitely prefer the approach that Solid takes. Ryan had an article at some point talking about this, but I can't seem to find it now. (it might have been just something he talked about in one of his very long streams.)
I'm generally opposed to function overloading and feel quite strongly about this - it's one thing to have one function performing the same (or very similar) operation on two different types of input, but it's another to have one function perform two very different (event opposite) functions. I like brevity as much as the next guy, but not at the expense of clarity - being able to scan the source code (visually) is very important, and the implications of reading versus updating state are critical.
I was also very excited about Haptic and the idea of making things more visible, and hence my interest in your project, so I'd expect maybe we have some of the same opinions on this stuff.
Just wondering how much consideration you gave to this issue?
Cheers. 🙂
Beta Was this translation helpful? Give feedback.
All reactions