SherylHohman / ReactND-C3-Project2-Readable

BSD 2-Clause "Simplified" License
1 stars 0 forks source link

move Reducers to their own files #48

Closed SherylHohman closed 6 years ago

SherylHohman commented 6 years ago

SUGGESTION 2/8 by reviewer2

Great work so far!

It's recommended to split each reducer into its own file, instead of utilizing one huge file to manage all your reducers. This keeps your code base cleaner, and allows other engineers to better analyze your application.

Here is a sample file structure you may want to consider:

'reducers/index.js ' (where you have your combine reducers, and import other reducer files)

/reducers/reducer1' (where you have one reducer that gets exported into reducers/index.js)

'reducers/reducer2' (same as reducer 1)

This improves your file structure making it easier to utilize and modify your application :muscle:

SherylHohman commented 6 years ago

1) I do NOT have all redcders in a single file! Each reducer is in it's own file. What I Do have is action creators, actions, and reducers, that are all related to a single store item, in a single ("ducks-like") file. That was much easier for developing code, as everything that was closely related was together.

2) That said, my files are now getting to the point where it makes sense to separate out my reducers to separate "ducks" files. I initially started out like that, but then found it cumbersome, co combined my "ducks" files into a single ducks file. Separate ducks exist for each reducer/store item.

3) Especially after I co-locate my selectors with reducers, I believe it's borderline time to go ahead and separate out reducers FROM ACTION CREATORS, ET AL, combining them into "ducks" folders, as I initially started out.