Search
  • Mike Malinowski

Plugged - Factory Library [GDC2018]

Plugged is a python implementation of the Factory/Plugin design pattern. The idea behind this pattern is to be able to define a structure for a plugin (a plugin being any piece of code that adheres to a strictly defined class structure and can therefore be interacted with in a consistent way). With a plugin structure defined, you can then implement pieces of functionality in a way which is completely encapsulated.



If you have access to GDC Vault, this is demonstrated in a talk I gave at GDC2018 (linked here)





If you're interested in playing with this approach, you can download the simplyfactory.py (linked here)






This module gives a demonstration implementation of a generic factory class. It does not offer all the bells and whistles you might want in a production environment, but it does give you enough to start playing and utilising the pattern.

Because each plugin is structurally the same, we can begin to interact with plugins without really needing to know what the plugin is doing at a detail level.


A use case for this kind of behaviour is a game exporter - whereby we may need to export data such as geometry, skeletons, cloth etc. Its all too easy to write all of this into a single monolithic exporter but that approach makes for an exporter which becomes hard to manage over time.

Instead, we can take the approach of defining an export abstract (shown below).




From that point we can start implementing plugins for discreet data types. For instance, having a plugin specific to exporting geometry, and a completely separate plugin for exporting cloth. By taking this approach we can very easily expand or contract the scope of our exporter without having to constantly refactor.


Our actual exporter can then be boiled down to some code which looks like that below.



  • github
  • Facebook Social Icon
  • LinkedIn Social Icon

©2018 by twisted.space.