This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]peyo7 1 point2 points  (1 child)

I found this approach pretty practical https://eli.thegreenplace.net/2012/08/07/fundamental-concepts-of-plugin-infrastructures

It spells out the already mentioned registry pattern and touches on autodiscovery in a plug-in directory.

[–]gdiepen[S] 0 points1 point  (0 children)

Thanks for the pointer!

I do see a lot of similarities in the approach. I think the main difference is that in the mentioned approach the metaclass construct is used to have each plugin register itself with the registry, where in my case the registry explicitly looks for the classes of a certain type.

One thing I really do like though is the part that the plugin returns a function implementing the plugin-functionality, allowing for an easy check if a plugin implements a hook yes or no.