Skip to content

Instantly share code, notes, and snippets.

@champi-dev
Created February 8, 2023 04:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save champi-dev/c6ebfabdc5fe539dcdedba5c52f12f98 to your computer and use it in GitHub Desktop.
Save champi-dev/c6ebfabdc5fe539dcdedba5c52f12f98 to your computer and use it in GitHub Desktop.
Split large code into many small files

Largo to Small

Yes largo, that's the name of this

The idea behind this is that in any case that you might find yourself having more than 40 - 80 lines of code in a single file you should split that file into smaller (therefore more readable) files.

How to

Follow the next convention

[folderName]

  • index.[ext] (entry file)
  • folderName.[name].[ext] (single file related to folder)

[utils] (...more on this later)

[components] (is a folder for pieces of logic, name this according to your coding context, e.g. frontend vs backend codebases)

  • index.[ext] (entry file)

  • components.[name].[ext] (single file)

[utils] (is a folder that handles small logic i.e. utiliratian files or functions)

  • index.[ext] (entry file)

  • utils.[name].[ext] (single util file)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment