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

Refactor modules structure to make it more domain-related instead of function-related #1071

Merged
merged 2 commits into from
Feb 24, 2025

Conversation

carbolymer
Copy link
Contributor

@carbolymer carbolymer commented Feb 24, 2025

Changelog

- description: |
    Refactor modules structure to make it more domain-related instead of function-related
# uncomment types applicable to the change:
  type:
  # - feature        # introduces a new feature
  # - breaking       # the API has changed in a breaking way
  # - compatible     # the API has changed but is non-breaking
  # - optimisation   # measurable performance improvements
   - refactoring    # QoL changes
  # - bugfix         # fixes a defect
  # - test           # fixes/modifies tests
  # - maintenance    # not directly related to the code
  # - release        # related to a new release preparation
  # - documentation  # change in code docs, haddocks...

Context

Change to domain-related modules structure

The present cardano-cli modules structure is as follows:

Cardano/CLI
├── Byron
├── Commands
├── EraBased
│   ├── Commands
│   │   └── Governance
│   │       └── Committee.hs
│   ├── Options
│   │   └── Governance
│   │       └── Committee.hs
│   └── Run
│       └── Governance
│           └── Committee.hs

it's spread across many different modules: Commands.Governance , Options.Governance, Run.Governance and multiple Types.Errors.GovernanceXXX. So right now you have to jump between different places to find code related to Committee, which is cumbersome.
Any future refactoring related to a single command would also require changes in three different places.

This PR changes the structure by 90 degrees and putting code into separate-ish domains instead, for example changing the above structure into this:

Cardano/CLI
├── Byron
├── Commands
├── EraBased
│   └── Governance
│       └── Committee
│           ├── Commands.hs
│           ├── Options.hs
│           └── Run.hs

(We could get rid of EraBased if there's a more elegant alternative).

This way you have everything related to a single command in one place which makes codebase easier to understand.

Aggregation of era independent commands

Additionally, era independent commands like address or hash are placed into Cardano.CLI.EraIndependent module to reduce clutter in Cardano.CLI module.

Use of singular nouns for module names

All module names which had plural nouns are renamed to use singular nouns in their names.

Comparison

Before:
before

After:
after

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff

@carbolymer carbolymer force-pushed the mgalazyn/refactor/reorganise-modules-structure branch 2 times, most recently from de52238 to ba8a497 Compare February 24, 2025 11:02
@smelc
Copy link
Contributor

smelc commented Feb 24, 2025

Big change! This is one that @Jimbo4350 should approve 🙂

@carbolymer carbolymer force-pushed the mgalazyn/refactor/reorganise-modules-structure branch from ba8a497 to d4d761d Compare February 24, 2025 11:14
@carbolymer carbolymer force-pushed the mgalazyn/refactor/reorganise-modules-structure branch from d4d761d to 5bec557 Compare February 24, 2025 12:23
@carbolymer carbolymer marked this pull request as ready for review February 24, 2025 12:31
@carbolymer carbolymer force-pushed the mgalazyn/refactor/reorganise-modules-structure branch from 7ae33d8 to 5df54ba Compare February 24, 2025 12:33
Copy link
Contributor

@palas palas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through the whole thing and I am pretty confident no code disappeared and no new code appeared. So, if it compiles, I think it is indeed a refactoring. But, I will leave approval to @Jimbo4350

@carbolymer carbolymer enabled auto-merge February 24, 2025 16:48
@carbolymer carbolymer disabled auto-merge February 24, 2025 16:57
@carbolymer carbolymer merged commit 63d001a into master Feb 24, 2025
27 of 30 checks passed
@carbolymer carbolymer deleted the mgalazyn/refactor/reorganise-modules-structure branch February 24, 2025 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants