Skip to content
/ Birdify Public

This project is a multi-module Android app with optional features (flying, swimming, singing) that can be conditionally included via build variants. Core logic (Bird) uses interfaces (CanFly, etc.) and a registry to access feature implementations. Feature modules use a FeatureInitializer to register with the registry.

Notifications You must be signed in to change notification settings

Fa-d/Birdify

Repository files navigation

This project is structured as a multi-module Android application designed to demonstrate how to implement optional features that can be included or excluded during the build process. The core of the project is represented by Birdy (the Bird class), which provides base functionality. Specific abilities or "features" like flying, swimming, or singing are implemented in separate, optional sub-submodules (flying_feature, swimming_feature, singing_feature). The optionality is managed by defining different build variants (product flavors) in the main :app module's Gradle file. These flavors conditionally include the desired optional feature modules as dependencies. To allow the core Birdy to interact with these optional features without crashing if they are not included, the project utilizes interfaces (like CanFly, CanSwim, CanSing) defined in a shared :bird_interfaces module. A BirdFeatureRegistry in this same module acts as a central point to access implementations of these interfaces at runtime. The selected FeatureInitializer interface, as shown in the Canvas, is part of a mechanism designed to automatically initialize the functionality provided by these optional feature modules if they are present in the build. Implementations of this interface within the feature modules would contain the logic to register their specific feature implementation (e.g., FlyingFeatureImpl) with the BirdFeatureRegistry. By discovering and calling these initializers (for example, using ServiceLoader as in a previous iteration of the solution), the core Bird class can then safely retrieve and use the feature implementations that are available in the current build. In essence, the project demonstrates a pattern for creating modular Android applications where features can be dynamically included or excluded at build time, and the core logic can safely adapt to the presence or absence of these features using interfaces and a registration mechanism.

About

This project is a multi-module Android app with optional features (flying, swimming, singing) that can be conditionally included via build variants. Core logic (Bird) uses interfaces (CanFly, etc.) and a registry to access feature implementations. Feature modules use a FeatureInitializer to register with the registry.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages