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

Internal: Consider refactoring towards 'FP' code, avoiding mutable state #135

Open
mrseanryan opened this issue Apr 1, 2020 · 1 comment

Comments

@mrseanryan
Copy link
Collaborator

Consider refactoring towards 'FP' code, avoiding mutable state.

The code may be simpler if we refactor to use a more 'Functional Programming' style, where we avoid mutating structures. (this is something I've learned more about recently :) )

In general this could make the code a bit easier to reason about, since a function would not modify its parameters (no side-effects).


example: analyzer.ts: - expandExportFromStar:


BEFORE

const expandExportFromStar = (files: File[], exportMap: ExportMap): void
  • takes 2 parameters
  • makes modifications to the 2nd parameter.

AFTER

A more FP signature would be like:

const expandExportFromStar = (files: File[], exportMap: ExportMap): ExportMap
  • takes 2 parameters.
  • Does NOT make modifications - instead, it returns a new ExportMap
@mrseanryan
Copy link
Collaborator Author

mrseanryan commented Apr 1, 2020

Marking as 'help wanted' since I think it could take quite a few iterations, and I'm not sure how much time I have free, until the Summer.

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

No branches or pull requests

1 participant