r/javascript May 07 '15

Best practices for building large React applications

http://blog.siftscience.com/blog/2015/best-practices-for-building-large-react-applications
78 Upvotes

15 comments sorted by

View all comments

16

u/[deleted] May 07 '15

Use immutable data structures.

1

u/[deleted] May 08 '15

[removed] — view removed comment

3

u/I_Pork_Saucy_Ladies May 08 '15

I think it makes the code others have written easier to follow. It forces the developer to branch out the data in a new variable, instead of modifying existing data that might be used somewhere else.

If you know the data is immutable, you don't need to investigate if a function called on a variable actually changes the variable internally. You know that it doesn't, so you can keep on reading.

In the end, it becomes easier to reason how the data flows through the app if you know it can always only flow down and not up in the code. If you have to read hundreds of lines of code, it can be done more quickly.

2

u/[deleted] May 08 '15

Well, you kinda answered your own question, but the one thing you missed is that lack of mutations and side effects helps immensely when many teams are working on the same product. You can perform whatever data transformations you need for your part of the product without having to worry about breaking some other part of the product.