concatenate icon indicating copy to clipboard operation
concatenate copied to clipboard

split

Open eleanorkonik opened this issue 2 years ago • 0 comments

Suggest splitting it up into e.g.

  • "filterFiles(path: Path)" to get a list of files according to your settings,
  • "extractContent(file: str, level: number, title: str)" to return the matched headings, and
  • "concatContent(content: str[])" to finally handle the concatenation

This way, you are able to test smaller portions of code, making it easier to concentrate on one part of the functionality instead of trying to keep the whole picture in your head. By being able to give all possible input (beside the settings) into the methods from the outside, you also get into the direction of building deterministic (sometimes called pure) function - those are side-effect free, meaning that they always will behave the same if given the same input. Those greatly help reduce mistakes and bugs and makes it easy to concentrate possibly problematic parts of your code (which usually all have some sort of side-effect like saving to a file, where a lot of things can go wrong that do not depend on your code) into encapsulated units.

eleanorkonik avatar Mar 13 '22 16:03 eleanorkonik