title: OOP - How to pass data "up" in abstraction?
body: <p>I have run into a problem when designing my software.</p>
  <p>My software consists of a few classes, <code>Bot</code>, <code>Website</code>, and <code>Scraper</code>.</p>
  <p><code>Bot</code> is the most abstract, executive class responsible for managing the program at a high-level.</p>
  <p><code>Website</code> is a class which contains scraped data from that particular website.</p>
  <p><code>Scraper</code> is a class which may have multiple instances per <code>Website</code>. Each instance is responsible for a different part of a single website.</p>
  <p><code>Scraper</code> has a function <code>scrape_data()</code> which returns the JSON data associated with the <code>Website</code>. I want to pass this data into the <code>Website</code> somehow, but can't find a way since <code>Scraper</code> sits on a lower level of abstraction. Here's the ideas I've tried:</p>
  <pre><code># In this idea, Website would have to poll scraper. Scraper is already polling Server, so this seems messy and inefficient
  class Website:
      def __init__(self):
          self.scrapers = list()
          self.data = dict()
  
      def add_scraper(self, scraper):
          self.scrapers.append(scraper)
     
      def add_data(type, json):
          self.data[type] = json
  
      ...
  </code></pre>
  <pre><code># The problem here is scraper has no awareness of the dict of websites. It cannot pass the data returned by Scraper into the respective Website
  class Bot:
       def __init__(self):
            self.scrapers = list()
            self.websites = dict()
  </code></pre>
  <p>How can I solve my problem? What sort of more fundamental rules or design patterns apply to this problem, so I can use them in the future?</p>