evancz / elm-architecture-tutorial

How to create modular Elm code that scales nicely with your app
https://guide.elm-lang.org/
BSD 3-Clause "New" or "Revised" License
4.17k stars 738 forks source link

fix: the view should not be reversing the string #103

Closed santoshjoseph99 closed 4 years ago

santoshjoseph99 commented 7 years ago

Documentation should be updated as well.

process-bot commented 7 years ago

Thanks for the pull request! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

evancz commented 4 years ago

I think it is better as it is in the example currently.

The model is storing the String input by the user. Having it be reversed is a strictly a matter of presentation, so it makes sense to do it in the view in my opinion. I think it's usually best to have a very clear and minimal Model, and derive as much as possible from that. Doing work in view is fine, especially if you use lazy. Pushing more information into the Model that is only for presentation should be an absolute last resort, only if there are performance issues that cannot be resolved by the normal techniques.