Note that there are some explanatory texts on larger screens.

plurals
  1. POSuggest OOP analysis/design - break my procedural habits
    primarykey
    data
    text
    <p>I would like to use OOP/OOD as an exercise for a small project, but I often find myself using a procedural approach when coding. I use Python in combination with Flask (web framework)</p> <p>In essence my app is a kind of spider that reads an rss feed for new movie releases. For each new movie release it uses the imdb link to gather information from two different web services (imdbapi and TMDb) regarding plot, year, genre, poster and info like that. If the preferred service cannot provide the information, then use the other service. Finally save all the info in a db. I then use Flask to present the information on a website</p> <p>I have created a Spider class for now. It contains the following methods (code removed for clarity):</p> <pre><code>class Spider(): """ Spider Class """ def __init__(self, rssfeed): def run_update(self): movie_list = self.get_entries_from_feed() self.get_imdb_json(movie_list) def get_entries_from_feed(self): """ reads an rss feed and return a list of lists with imdb id, title, and added date time """ def get_imdb_json(self, movie_list): """ get json data from imdbapi based on list with imdb id""" if not in db: save_to_db def save_to_db(self, key, nzb_title, added, data): """ save entry to db from json data""" </code></pre> <p>The "problem" is that I use the <strong>run_update()</strong> method to carry out all the steps in a procedural way. I also find the design inflexible. E.g if I can't get movie information for one service i'd like to try the other service, but this is not very easy to implement in the current format.</p> <p>What I have thought about is to create a Movie class, representing each movie found in the rssfeed. Maybe also to create classes for each of the services I use for gathering information about each movie, imdbapi and TMDb?</p> <p>So, how would you go about and design an app like this in an OOP/OOD fashion? I find it a little hard to identify classes, when we are beyond the simple examples used in text books - like cars, books, fruits and etc.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload