jaredwray/cacheable

Code has growin big. Break it into parts.

Closed this issue · 5 comments

This library source code resides in single javascript file and has almost no comments. It can become hard to maintain in future. The code needs to be divided in smaller modules.

I agree the code is hard to follow, not sure breaking it into separate files will help too much though, although I'm not strongly against it.

Things that would help:

  • Adding comments
  • Refactor into using function composition instead of being a class (Writing as a Class was a mistake)
  • Having more named functions and calling them rather than having large chunks of code inline

I imagine that would increase readability quite a lot.

If those are done and it's still hard to follow it would be easy to split up by just extracting the named functions into their own files.

Actually yes, dividing in smaller functions is also a good idea. I will start work in that direction once testing issues are fixed. Don't want to shake this when unit tests are failing.

Now that tests are working fine, I am starting some work on this. I will send PRs with small changes. Plan is to eventually divide entire codebase in smaller functions.

There was some activity on #30 the other day. It might be better to wait and see what happens with that before starting to refactor things.

Otherwise whichever gets merged first is going to cause a lot of conflicts for the other.

I have checked and commented on it. It seems there is still no PR for it and I will most likely get it resolved as per that discussion output during code-refactor exercise.