projects as composition of submodules

motivation

Note: when writing code as a composition submodules I've never encountered a bug I could not deal with, this comes from the fact that you can easily isolate parts of the code and test them independently, then re-integrate.

moreover using a codebase structured with reusable pieces of logic stored in submodules offers several benefits, particularly when managing complex or large-scale projects. Here’s the reasoning behind this approach:

Modularity and Reusability

By breaking down the codebase into submodules, you can encapsulate distinct pieces of functionality or logic into separate, reusable components. This modular approach allows you to develop, test, and maintain each submodule independently, avoiding code duplication and making it easier to reuse common logic across different parts of your project or even in different projects.

Isolation of Changes

When changes are needed, isolating those changes to specific submodules helps manage their scope and impact. Each submodule can be updated independently, reducing the risk of unintended side effects in unrelated parts of the codebase.

Enhanced Version Control

Each submodule has its own version history and can be versioned independently, allowing for precise tracking of changes and easier rollbacks if necessary. This makes versioning and releases more effective.

Consider this approach only if you are certain that you will be reusing pieces of code in a specific domain. It is most beneficial when you are committed to a particular language or technology stack. Otherwise, the overhead of maintaining multiple submodules may increase complexity without providing significant benefits. Evaluate whether modularization outweighs maintenance costs in your context.

operation

Making Changes

If you have a goal to update the project, make the necessary changes in each relevant submodule. This could involve bug fixes, new features, or updates to align with new requirements.

Committing Changes

For each submodule, commit the changes with a clear message detailing what was changed and why.

Updating the Main Repository

After committing changes to the submodules, update the main repository to reflect these changes:

Describing the Net Effect

In the main repository’s commit message or associated documentation, provide a summary of how the changes in each submodule impact the entire codebase.

Example Directory Layout and Workflow

/main-repo
/submodule-A (logging utilities)
    - Commit: "Fixed bug in logging utility affecting asynchronous operations"
/submodule-B (data processing algorithms)
    - Commit: "Updated data processing algorithm to improve performance"
/submodule-C (UI framework)
    - Commit: "Enhanced UI framework for better scalability"
/docs (documenting net effect)
    - Summary: "The bug fix in logging utilities, improved data processing performance, and UI framework enhancements boost overall application performance."
/scripts (automation scripts for building and testing)
    - Update script to reflect the new versions of submodules.

Root repository commit:
- Commit: "Updated submodules to include fixes and improvements: logging utility, data processing algorithm, and UI framework"

edit this page