bulletproof-react icon indicating copy to clipboard operation
bulletproof-react copied to clipboard

About features/feature folder rules

Open mamaredo opened this issue 3 years ago • 2 comments

Thanks for the great resources : )   I am designing an application based on this document, but I have a question.

What I want to ask you

project-structure.md

A feature folder could also contain other features (if used only within the parent feature) or be kept separated, it's a matter of preference.

  • For the definition of the bolded part

Specifics

Although it is defined to be used only within the parent feature,    features/comments is referenced in features/discussions, lib/authorization.tsx.  

Also, features/users is referenced in features/comments, lib/authorization.tsx, and route/protected.tsx.   Aren't features that are imported as new features supposed to be used only by the parent feature that imported them? I wondered.  

However, when I took a closer look at the source code, I found that the part I was wondering about had one thing in common.   It was that I had imported the Typescript types used in the functional folder.  


Based on the above, I would like to ask you three questions.

  • Can I import the types defined in TypeScript, since they are not features themselves?
  • features/comment is used in features/discussions, but Can a feature other than features/discussions use features/comment?
  • featureA <- featureB featureC <- featureA Is this kind of dependency possible?   I can't provide a specific situation where this is needed, but I would like to know if features can be used as grandchildren in features.

mamaredo avatar Feb 11 '22 09:02 mamaredo

Hi there,

Q: "Can I import the types defined in TypeScript, since they are not features themselves?" A: Yes you can, just make sure you are exporting the types from the index.ts of a given feature.

Q: "features/comment is used in features/discussions, but Can a feature other than features/discussions use features/comment?" A: It can if it needs to, however, since the application is simple, we don't need to do that.

Q: "featureA <- featureB featureC <- featureA Is this kind of dependency possible?   I can't provide a specific situation where this is needed, but I would like to know if features can be used as grandchildren in features." A: It's difficult to tell without a concrete example, but it looks like this might cause the circular dependency issue. But that would also depend on what exactly you are importing from each feature.

alan2207 avatar Feb 27 '22 08:02 alan2207

Thank you for taking the time to reply!😄


A: Yes you can, just make sure you are exporting the types from the index.ts of a given feature.

I understood that the type is not an entity of the feature, so if it is exported in index.ts, it is not included in the constraints of the feature and can be imported and used from any module.


A: It can if it needs to, however, since the application is simple, we don't need to do that.

So featureA and featureB with different contexts can be used as a common feature and featureC as a child feature?

I'm sorry. I wasn't asking the right questions to get what I wanted to hear out of you. What I wanted to ask was. A feature folder can contain other features (if they are only used within the parent feature). Here's a bad example that applies here


It's difficult to tell without a concrete example, but it looks like this might cause the circular dependency issue. But that would also depend on what exactly you are importing from each feature.

I should have thought a little more before asking my question. After asking the question, I thought about it for a while, but I couldn't find a suitable case. Besides, if it is a simple feature, it may not be a big problem, but if the impact of the feature is spread too widely, it may ruin the clean architecture.


And I have one more question, but it shouldn't be addressed in this issue, so I've created a separate issue -> issue#64

mamaredo avatar Mar 01 '22 05:03 mamaredo