DEV Community

Discussion on: Organizing MVU Projects

Collapse
 
brucou profile image
brucou

That is super interesting. I am (was) a big fan of Elm, but TEA remains a really good way to think about an application behavior. One issue I always had was that of modularization. It is great to see how you handled it, and also the link
to Elm's documentation: guide.elm-lang.org/webapps/structu...

I am thinking of using TEA or variant in JS which works great, but you don't have the safety net of a type system. So instead I use tests. A user scenario is a sequence of events, and because the update function produces no effects, I just have to either check properties or expected outputs when running the sequence through the application. I have to learn F# to see what is the produced output. But I am happy I don't have to do all this type gymnastic. Types avoid bugs, but you get most of those bugs anyways - given enough tests. At least that's my impression so far.

Collapse
 
kspeakman profile image
Kasey Speakman • Edited

Thanks for your response. :)

I agree that types mostly aren't helpful for avoiding bugs. They can be if you design types which cannot have invalid values. I do this when it is convenient, but usually this is not worth the effort for me. Because to do so, the type effectively becomes an OO object with behavior bound to private data. And maintaining it in the future means maintaining that facade's overhead. I like FP because I prefer being able to compose data separately from behavior, and keeping both of them relatively simple, so I do not do this that often.

While messing with Clojure, I recently rediscovered why I DO like types. It's because I have ADHD and a small working memory. Sometimes I had to swap back and forth between the file generating the data and the file consuming the data multiple times before retaining enough to write the consuming code. By using types and tooling assistance, I can have auto-completion of valid properties or can lookup the specifics of the data provided to me on the other end. And even without ADHD, types can be helpful for the same reason as programs get large, because the working memory required is too big for most humans. Types definitely have undesirable maintenance overhead, but for me it is worth paying. Maybe not for everyone.

Collapse
 
brucou profile image
brucou

How interesting. I'd rather not know if I have ADHD but I do have a short-term memory and I am almost never programming more than 2 hours in a row anyways. I solved the get-back-in-the-flow issues with writing docs first and filling the code in the middle -- and leaving a test failing here and there. I am almost more of a writer than a coder but then after leaving notes to myself for a few years, I find it easy to write any kind of technical article. Tooling helps for sure, and I love the types that I don;t have to write. I get the benefits without the trouble :-)

Thread Thread
 
kspeakman profile image
Kasey Speakman • Edited

For me I was literally not remembering the property names and types I just looked at or typed into one file and needed to now consume in another. (I remembered them, but not precisely -- spelling/capitalization/exact term etc.) Maybe all these years of types have trained my behavior that I don't have to. 😂