> 1. Motivation and Goals
The initial reasons for starting these thoughts were a combination of discussions within the WoW UI Community over library best practices, and attempts to wrap some of my own utility code up in a manner that was easy to use for other authors while remaining relatively efficient.
The goals of this document are as follows:
An Embeddable Approach
Describe an approach for embedding common library code within the AddOns that need it, so they can be distributed easily (And so that multiple versions can co-exist)
Easy to Use
AddOn authors who just wish to use a library must be able to do so easily, and let the library worry about versioning and resources by itself.
Multiple identical (or compatible) copies of the library must be merged so that only the most recent one remains. We cannot really avoid having to load them all, but once the load phase is complete the minimal necessary set will remain in memory.
Robust and Predictable
The embedding scheme must support all initialization methods (Normal AddOns, LoadOnDemand, etc) and library evolution (Major and Minor versions, forking). In addition, the expected behavior of the scheme under each condition must be documented so that it can be used without uncertainty.
Straightforward to Implement
Finally, the scheme must be straightforward for library authors to implement, with as small an amount of boilerplate code as possible. There's no sense having an embedding scheme if the complexity of implementing it scares everyone away.
The rest of this document is as follows:
2. Library Approaches introduces the various ways of dealing with common libraries in WoW.
3. Component Design presents an approach to meeting the goals.
4. Implementation Code provides the code required to implement an embedded shared library.