I am new to programming. I recently read that:
Your program should have almost all functions encapsulated in either functions or class methods
It seems like I should not have both functions and methods. I also read that methods should be short and simple.
Well, I recently made a small program that downloads images from blogs. I used OOP classes and approach because I need to inherit certain things.
However, since the methods must be short and do one thing, my program cannot do much. My question is: if I try to use a clean OOP approach, how can I avoid writing functions?
My script follows basically this scheme:
class Tumblr(object): def __init__(self, user): self.user = user def get_posts(self): """Use tumblr api to return a user posts.""" return client['blog']['posts'] def parse_images(self): """Returns images.""" images = [] for post in posts: if 'image' in post: images.append(post['image']) return images def parse_videos(self): """Returns videos.""" def main():
I also have other classes for different website APIs, as well as the Downloader class, which actually downloads files to disk and to the corresponding directory. The problem is that now I have all these isolated classes and methods.
I thought about creating a main function that can also use other functions, but then again, I don't think this is the correct OOP.
How can I get a job without writing functions? (The textbooks I read said that functions should not be used in pure OOP if I use methods.)
source share