Replies: 5 comments 11 replies
-
To elaborate a little on the above, from my perspective:
Also, I think we shouldn't be too dogmatic about the above. There are always exceptions, and I think following architectural rules to the letter can end up worse than making a practical exception. The end goal is to make anyone working on your code hate you as little as possible. |
Beta Was this translation helpful? Give feedback.
-
I couldn't agree more, great salient points! Succinct and direct, not too many rules to follow. |
Beta Was this translation helpful? Give feedback.
-
This is a minor thing, but we use different standards of folder and filename naming (extensions, capitalizations, etc.). Would be nice to settle on a single convention and just lint that. Say with something like https://ls-lint.org, https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/filename-case.md or similar. |
Beta Was this translation helpful? Give feedback.
-
@Mohammer5 and I were talking about this, and thought that once we've settled on something we all like, we could test it out on:
Those are all a little different, but all modern apps. Could make for a good way to test whether what we've decided on is practical. |
Beta Was this translation helpful? Give feedback.
-
@ismay, @HendrikThePendric and I talked about this and what we figured out deviates from the current proposal: Why are we talking about this in the first place?Before talking about the solutions, we have to have a problem in the first place. We found the following problems
Issues with defining a clear rule setIdeal organization within an app depends on the size of an app@ismay found some good articles about this topic while doing some research. This article highlights an important aspect of organizing apps: It really depends on the scale of the project.
The reason why this is important is: There's no one size fits all solution It's hard to find a definitive distinction between different variations of complexityAs described above, different levels of complexity require different approaches to organizing the code. If we want to define rules how to organize an app, we need to find a rule set that's unambiguous. And this is very things get really tricky. It was quite straight forward to us to extract rules from existing apps, but we quickly figured out that it doesn't necessarily make sense to apply these rules to different apps. Some other apps with a recent overhaul that have different levels of complexities are:
Alternative approaches to having a strict rule setThe actual organization is not that important, it "just" has to follow a few abstract rules
As our apps or basically react component (the index file is a react component), the organization should be by "concern" or "function"
As different developers do things differently anyway, we shouldn't enforce a static app organization. Instead we should focus on having examples for different degrees of complexity and instead keep in mind that apps are also "living" and are bound to change over time, so it's really about being able to adapt easily to new requirements, also on the organizational level
I guess what we could do is to highlight different solutions, everyone can share opinions on the solutions, add their own solution to the discussion so we have both a catalog of solutions for different problems as well as a discussion about what we like the most. We might come to a conclusion that some guidelines and/or rules apply to all scales, we might find some complexity levels that we can generalize and turn into guidelines and/or rules. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've talked to @ismay about what we think is the cleanest way to design our apps in regards to file/folder architecture.
What we've agreed on so far is:
Pages should be organized similarly to what next.js does
On the root level there should be a
src/pages
(orroutes
orviews
) folder.Inside the components the organization is similarly to what the navigation tree looks like:
In our case, there's no magic that does that for us, but we like the structure. It's clear, scalable and easy to reason about.
Additionally this is where integration tests can be done as the components in the
pages
folder are MVC-Controller-like (composing functionality from building blocks)src/components
andsrc/utils
In order to be able to compose the pages, all our apps need reusable components. @ismay's and my preferred approach would be to have a ducks-like structure inside the
components
folder (group things by namespace).The
src/utils
folder is an optional third folder, which can be used when code doesn't fit into one of the component-folder's namespaces (e. g. array helpers, etc)Hooks
With graphql it's good practice that every component defines its own query when it needs data. Abstracting the data fetching into shared / re-usable hooks can have undesired side effects (like loading data that's not needed when changing the query slightly for a different area of the app), so instead of also adding a
src/hooks
folder, it's better to co-locate components with their query/mutation definitions.Forms
Instead of using configs, we prefer if forms are implemented using components. This way forms are lot easier to implement and to reason about, dynamic forms always have been a pain in my experience.
Using components instead of configs, forms become scalable
Beta Was this translation helpful? Give feedback.
All reactions