ForrestKnight / yt-dislikes

Add the dislike count back to my YouTube videos via a comment containing that information.
https://youtu.be/1uAH93tzfQY
MIT License
155 stars 13 forks source link

Improve readability and testability of code #11

Open joeyshi12 opened 2 years ago

joeyshi12 commented 2 years ago

Issue

Having all the logic bundled within a single main method is difficult to understand and test, so I broke up the code as much as I could in a way that could address both these problems.

Changes

Screen Shot 2021-11-23 at 12 44 22 AM
ForrestKnight commented 2 years ago

A lot of this is very helpful! I haven't gone through all of it, but I will. The only issue I see with it is that it's quite a bit different from the YouTube Data API doc code. That may be better, but it could cause some trouble in the future for others trying to understand the code. Let me think on this a bit longer.

joeyshi12 commented 2 years ago

A lot of this is very helpful! I haven't gone through all of it, but I will. The only issue I see with it is that it's quite a bit different from the YouTube Data API doc code. That may be better, but it could cause some trouble in the future for others trying to understand the code. Let me think on this a bit longer.

Good point. I can isolate some of the YouTube boilerplate code better and remove some of my changes to that specific part later. But, I think using an adapter for the api client helps to unbundle some complex logic in the main method and it will also offer some nice auto-completion hints from the ide (good for potential contributors) since we would have an interface for the api client in the codebase.