Hmm... You're saying that the order of initialization of plugins matters? In my opinion that's a poorly designed system. Ideally plugins should be self-contained and independent.
But fine, if it's absolutely necessary that some plugins depend on other plugins then either:
1. The user should be able to specify the order of initialization. This is what's done, for example, for Skyrim mods. This is a really simple solution, but the problem is that it puts the burden of doing things correctly on the user, and the system can become frustrating to use when many plugins are being used.
2. Plugins should be able to identify themselves uniquely (e.g. using a GUID) and declare on which other plugins it depends on. For example, this could be done through a manifest (a text file):
1 2 3 4 5 6
|
id = ff0a03cd-236a-483d-a144-0837259e3604
dependencies = {
a8c3e163-0730-4388-8804-b96a898e7ab9
67d3aba5-8a08-46eb-9128-31b4d057488c
af2fa939-ff7f-4580-96cb-d678d59aafcd
}
|
Then before initializing the plugins, the loader must use this information to build a directed acyclic graph (DAG) describing the dependencies of the entire system and sort it topologically (
https://en.wikipedia.org/wiki/Topological_sorting ). The sorted sequence then describes the order in which the plugins should be initialized so that there are no conflicts.
Obviously this solution is more complex, but it solves the problem of order of initialization completely, dynamically, and without user intervention.