I am writing a system of callbacks for BitBucket and GitHub which should modify our site on certain events in BitBucket or GitHub.

It is reasonable to make a base class like GitIntegration to handle both BitBucket (BitBucket class) and GitHub (GitHub class) as its inheritors. Note that these three classes are agnostic of our site. Their only responsibility is to communicate with BitBucket and GitHub, not to do anything with our site.

But there is yet another class in the play (let's call it OurSiteGitIntegration) which will do actual modification of our sites, when he receives messages from either BitBucket or GitHub.

We need to somehow connect OurSiteGitIntegration with particular code for BitBucket and GitHub.

The best idea I've come up is the following:

Make OurSiteGitIntegration an abstract class and create two mixins:

  1. OurSiteBitBucket(derived from OurSiteGitIntegration, BitBucket)
  2. OurSiteGitHub(derived from OurSiteGitIntegration, GitHub)

Is there an even more concise and straight way? (without the mixins)

I use Python Django.

  • 3
    I feel like there's a really good question in here somewhere, but it's lacking enough details to properly answer. – RubberDuck Nov 9 '16 at 22:21

Hope I understood your question correctly.

I would keep the OurSiteGitIntegration away from interacting with BitBucket class and GitHub class.

Just run each one of them in a seperate thread/process and write events to a queue to be consumed by OurSiteGitIntegration

I imagine (correct me if i'm wrong) you will be polling on Github and Bitbucket for events, and once something you looking for happens, you will apply changes to you site (could be helpfully if you can specify what type of change you intend to do on your site)

So again by using an internal (or external, if you want to scale) queue to queue events of interest from Github and Bitbucket and consume those events with OurSiteGitIntegration
will allow you to run everything asynchronously, And generalize it enough to allow easy integration of new sources.

Always try to think about what changes will be required if you'll need to add another source (like Gitlab) how easy will it be to integrate it into your design.

most of the boiler-plate code can be abstracted with celery

hope that helped

  • Sorry, but your answer is unrelated with my question. I asked about class hierarchy (or composition). You answer is about implementation. I have not asked about implementation, just about the OO stuff (public interface only) – porton Nov 12 '16 at 13:15
  • @porton: your question feels very much like implementation question, and specifying Django and tagging your question the way you did reinforces this feeling. Personally, I understood your question similarly to Urban48, so consider either editing it or, even better, accepting Urban48's answer and asking a different, more specific question. – Arseni Mourzenko Nov 12 '16 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.