Patterns to refactor common code in multi-platform software

Posted by L. De Leo on Programmers See other posts from Programmers or by L. De Leo
Published on 2012-10-31T14:56:20Z Indexed on 2012/10/31 17:12 UTC
Read the original article Hit count: 372

I have a Django application and a PyQt application that share a lot of code. A big chunk of the PyQt application are copied verbatim from the Django application's views. As this is a game, I have already an engine.py module that I'm sharing among the two applications, but I was wondering how to restructure the middle layer (what in Django corresponds to the largest part of the views minus the return HttpResponse part) into its own component.

In the web application the components are those of a classic Django application (with the only exception that I don't make any use of models):

  • the game engine
  • the url dispatcher
  • the template
  • the views

My PyQt application is divided into:

  • the game engine
  • the UI definition where I declare the UI components and react to the events (basically this takes the place of the template and the url dispatcher in the Django app)
  • the controller where I instantiate the window object and reproduce the methods that map the views in the Django app

© Programmers or respective owner

Related posts about design-patterns

Related posts about architecture