mulesoft-labs / mule-match

A simple swapping app to use as a Reference app for React applications.
MIT License
6 stars 2 forks source link

About "Domains" #8

Open martin-eq opened 8 years ago

martin-eq commented 8 years ago

This is the first time I see a "domains" structure in a Redux project. It's been a while since the last time I worked in React, so I thought it would be a new concept introduced by Redux, but I couldn't find information about it in the documentation.

The projects that I worked in followed a folder structure similar to the one in the Redux's examples

I'm curious about how you came up with the "domain" concept.

nanovazquez commented 8 years ago

Hello @martin-eq ! Sorry for the late response :(

The folder structure for the Redux examples can work with simple, small projects. But it does not grow well when working on real-life projects with several pages. Based in our experience, the structure you mention does not help the adoption of newcomers and could end up in a really messy project, in terms of file/folder structure.

The domains folder gathers all the entities/files that work with the Redux global state. This approach was originally inspired by this post, but after some discussions I decided to used domain to gather the action, reducers and selector to reuse this logic in more than one component. At the same time, it helps finding the right information in the right place and ease maintainability of the code (avoids duplication of selectors, adding code in the wrong place, creating files when is not needed, etc).

Also, notice that this approach follows Redux suggestions for separating presentational logic and state manipulation, aka dumb & smart components respectively (see here).