4 ms·
The primary reason to make YoutubeSearch a class is, in the future, implementing searching other video sites and taking advantage of inheritance in the implemen
by jspthrowaway2 14y ago
The primary reason to make YoutubeSearch a class is, in the future, implementing searching other video sites and taking advantage of inheritance in the implementation. That isn't demonstrated here, but the plumbing of "doing a request", "providing an iterator" and such could be promoted to the base class and subclasses are only responsible for knowing their domain.
- wahnfrieden 14y agoYAGNI and besides you can still provide two layers of access, one being convenience functions on top of the class implementation.
- icebraining 14y agoWhen you actually want to implement those other sites, you can replace the function by a class with a __call__ method.
- hcarvalhoalves 14y agoThere's no practical difference between a method and a class in this case.
- mercurial 14y agoHaving YoutubeSearch be a class doesn't really bother me, especially since the point of the post was to demonstrate the use of __ methods, and you can't do that if you're using a method instead. However, I discourage promoting inheritance (except in the guise of mixin, and even then...) as a way to factorize common functionalities. Composition is usually much better suited.