A small Flutter project to demonstrate the concept of Modularization in project.
Please refer to Pokemon Quiz App} for Newer Version of Modulariation.
Modular programming is a software design technique to separate functionality into independent, interchangeable module, so that each contains everything necessary to execute a specific functionality.
Android equivalent concept: https://www.youtube.com/watch?v=PZBg5DIzNww
Techniques:
- Feature Based
- Layer Based
- Hybrid Based (Feature and Layer)
There many other ways to distribute the app but these are the basic/general techniques.
In this technique one distribute the app in different feature modules where each module is self sufficient and independent. This give the power of plug and play but at the same time the inter dependent features suffers since it increases the complexity of sharing in between features.
In this technique one distribute the app in layers of functionality. This makes the app testable and provide true meaning of SOLID principles. But this type is not very helpfun in complex/feature dependent app.
In this technique one combines both of the above techniques. Certainly this increases the app complexity but at the same time provide lot of freedom and interchangability.
Pro:
- Seperation of Concern
- Maintainablilty
- Testable
- Reusability
- Faster CI/CD (Not 100% sure)
Con:
- Slower development
- Could be an over kill if feature is small
- Increases code cmplexity
The app is very basic with networking and few main features:
- Getting current location
- Display current AQI
- Get AQI forcast
- Get last 7 days AQI history
- Setting (Theme, Language etc)
- Add location (Pending)
- Add Feedback (Pending)
Modules in the App:
- layer/domain Module
- layer/data Module
- utility/common Module
- utility/analytics Module
- utility/component Module
- feature/forecast Module
- feature/history Module
- main
This module is responsible for defining the business logic. It provides definitions and it is pure dart.
This module is responsible is fetching data and hooking the data with domian definitions. The data could be local, remote, locations, sensors etc.
This module is responsible for providing common stuff throughout the app. This layer could/should be independent of any external libraries. The things it could include are: Exceptions, extensions, mappers defnitions etc.
This module is responsible for providing analytics throughout the app. This could be also the part of common layer.
This module is responsible for providing basic building block widget for the presentation(main) and feature modules.
These modules are feature based which mostly has presentation layers.
This module has basic setup for all the app which could be theme, global state, routes etc.
mkdir layer
cd layer
flutter create --template=package domain
In flutter environment the following could be challenges:
- Navigation between feature modules
- DI for modules
- Module inter dependencies
- Clean Arch
- DI
- Riverpod State Management
- Analytics (Pending)
- Firebase Connection (Pending)
- Localization (Pending)
- Theme
- Add Location (Pending)
- Flavours (Pending)
- Build Type (Pending)