openfoodfacts / smooth-app

The new Open Food Facts mobile application for Android and iOS, crafted with Flutter and Dart
https://world.openfoodfacts.org/open-food-facts-mobile-app?utm_source=off&utf_medium=web&utm_campaign=github-repo
Apache License 2.0
741 stars 260 forks source link

Refactoring: smaller dart files #1712

Open monsieurtanuki opened 2 years ago

monsieurtanuki commented 2 years ago

Just a suggestion: once in a while, if we find "too big" dart files, we should split them in several dart files. Could be helpful for focus and maintenance reasons.

Counting the lines in shell:

find . -name "*.dart" -exec wc -l {} \; | sort -nr

First results:

     667 ./generic_lib/dialogs/smooth_category_picker.dart
     617 ./pages/product/summary_card.dart
     478 ./pages/product/common/product_query_page.dart
     469 ./pages/product/nutrition_page_loaded.dart
     433 ./pages/question_page.dart
     356 ./pages/user_preferences_dev_mode.dart
     356 ./pages/product/new_product_page.dart
     356 ./cards/product_cards/knowledge_panels/knowledge_panel_table_card.dart
     350 ./pages/product/common/product_list_page.dart
     335 ./pages/user_management/sign_up_page.dart
     334 ./pages/product/edit_ingredients_page.dart
     317 ./pages/product/nutrition_container.dart
...

Subtasks:

adilwahla commented 1 year ago

sir can i do this?

monsieurtanuki commented 1 year ago

@adilwahla I'm not a big fan of refactoring for refactoring, especially as there's plenty to do in "real" code. This issue is more like a "warning" to developers: "hey, when you code, don't write files that are too long, and if you can, split them, for clarity". That said, what about first refreshing the top 10 list of longer dart files in the app, with their number of lines?