protostar icon indicating copy to clipboard operation
protostar copied to clipboard

Refactor project structure

Open kasperski95 opened this issue 2 years ago • 6 comments

Previously, features specific to a command were kept in the command folder. As the application grow, features started to be shared across multiple commands.

Suggested project structure:

protostar
  - commands
      - build_command.py
      - ...
  - shared                      # keep it small — increases coupling
      - constants.py        # e.g. link to the protostar repository
      - protostar_exception.py
  - features                    # contains only packages not modules
      - cli
      - starknet_gateway
      - starknet_compiler
      - testing
      - ...
   - protostar_cli.py
   - composition_root.py
   - start.py
  • commands can import from shared, features and other commands
  • features can import from shared other features

kasperski95 avatar Jul 18 '22 11:07 kasperski95

sorry for being that guy, but I don't personally see a need to have distinct shared and features hierarchies. There's no added value over putting shared stuff under protostar and particular features under protostar.testing or protostar.starknet_gateway for example.

but this is a matter of taste :)

mkaput avatar Jul 18 '22 13:07 mkaput

I don't have a strong opinion on the project structure, but I'd like to define some structure we try to follow.

You're right, Shared/Utils/Core is probably a bad idea.

Features is a pattern from Redux Toolkit but I don't have a strong opinion on that either.

kasperski95 avatar Jul 18 '22 13:07 kasperski95

@MaksymilianDemitraszek @Radinyn opinions?

mkaput avatar Jul 18 '22 13:07 mkaput

There are definitely some benefits coming from @kasperski95 proposal but honestly I don't see much issue with the current structure. It's true that test command dir became a bit bloated but generally stuff included there is not shared outside of the command, so hoisting it up to some arbitrary dir abstraction IMO will make it more confusing.

Generally I would prefer to not adapt structure from a frontend framework as it is designed to generalize among many possible apps (to make developers working in many apps using the same framework easier and work well with abstractions provided by the framework). If we are not using a framework we can let dir structure grow at its own pace and address problems reactively the way that fits our domaia.

Summing up, I think we just cannot come up with an arbitrary structure that will address all of our future problems, because we just can’t predict the future.

I hope it makes sense and thank you @kasperski95 for your contribution I think the general idea is very good just maybe not worth adressing ATM.

MaksymilianDemitraszek avatar Jul 19 '22 09:07 MaksymilianDemitraszek

Right, I'll follow this pattern then. I'll not use utils directory.

protostar
  - commands
      - build_command.py
      - ...
   - feature1
   - feature2
   - feature3
   - ...
   - protostar_cli.py
   - composition_root.py
   - start.py

kasperski95 avatar Jul 19 '22 10:07 kasperski95

Generally I would prefer to not adapt structure from a frontend framework

@MaksymilianDemitraszek You already do https://react-file-structure.surge.sh/

kasperski95 avatar Jul 29 '22 22:07 kasperski95

It seems we use Screaming Architecture. Closing.

kasperski95 avatar Oct 12 '22 09:10 kasperski95