Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use barrel files for features #449

Open
marfavi opened this issue May 11, 2023 · 3 comments
Open

Use barrel files for features #449

marfavi opened this issue May 11, 2023 · 3 comments
Assignees
Labels
code/dev DX; technical debt; issue concerns code readability or quality research Further research is needed

Comments

@marfavi
Copy link
Member

marfavi commented May 11, 2023

A barrel file is a file in a folder that exports all dart files within it.

It greatly reduces the amount of imports in files that need to refer to a feature, improving code legibility.

There's an extension that can generate these files for us.

https://marketplace.visualstudio.com/items?itemName=miquelddg.dart-barrel-file-generator

@marfavi marfavi added the code/dev DX; technical debt; issue concerns code readability or quality label May 11, 2023
@jonasanker
Copy link
Member

jonasanker commented May 11, 2023

I think we should be very mindful about the trade-off. It might be that it makes imports looks smaller but it also hides usages of files, can affect refactorings and lead to importing more than what is needed.

I would question if this would solve a real problem for us compared to possible side effects.
It's probably more a code design smell that our features are not cleanly designed if we have a need for Barrel files.

See this opinionated blog on Barrel files https://steven-lemon182.medium.com/are-typescript-barrel-files-an-anti-pattern-72a713004250

@marfavi marfavi added the research Further research is needed label May 11, 2023
@marfavi
Copy link
Member Author

marfavi commented May 24, 2023

I agree with you @jonasanker. Closing this issue

@marfavi marfavi closed this as not planned Won't fix, can't repro, duplicate, stale May 24, 2023
@marfavi
Copy link
Member Author

marfavi commented Jan 29, 2024

Re-opening with POC pull request at #570.

The interest for barrel files now stems from the desire to keep feature changes encapsulated, meaning that if I change one feature, we want to minimise the amount of file changes from outside that feature. Let's talk

@marfavi marfavi reopened this Jan 29, 2024
@marfavi marfavi self-assigned this Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code/dev DX; technical debt; issue concerns code readability or quality research Further research is needed
Projects
None yet
Development

No branches or pull requests

2 participants