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] Code-cleanliness recommendations #196

Open
pjfitzgibbons opened this issue Sep 20, 2023 · 0 comments
Open

[REFACTOR] Code-cleanliness recommendations #196

pjfitzgibbons opened this issue Sep 20, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@pjfitzgibbons
Copy link
Contributor

Is your feature request related to a problem?
This is a follow-on from PR #148

From the call to getOpenSearchData, it seems that this is not a fetching function, this function is picking the selected data fields out of each record of the given arrayHits.

  1. rename getOpenSearchData. Something that describes what is happening to the data - "pickFeildsFromDataArray" ?
  2. divide and encapsulate the code to find the field within the hit-object. This will make the loops within the function much easier to read.
  3. divide and encapsulate the date-management code. The date-formatter, and the conditional to detect a date, should both be single functions with simple input (1 or 2 args only).

While you're constructing code, always be thinking about how that code "tells a story". Reading lines of syntax is very difficult cognitively -- yes that is why we are hired to do the job we're doing (because we're good at reading code) -- our job is more than that though. We need to write code that is easier to understand to someone else... and to your future self. Use function names that convey the intention of that step in a process. Collect lines of code together that accomplish a thing, and put them in a function. Even when the function has only one usage... a well named function will save millions of exhausted brain cells the next time somone (or You!) need to read and undersand that code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants