MayronObjects - An OOP framework with low memory usage - WoWInterface
Thread Tools Display Modes
12-07-20, 04:17 AM   #1
A Frostmaul Preserver
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 266
MayronObjects - An OOP framework with low memory usage

I have seen a lot of different OOP solutions for WoW addon development in the past. Still, I have been using my own for many years, and it has saved me much time debugging tedious issues while also providing an exceptionally smooth development experience. It's packed full of useful features (all of which I have ended up needing) while also providing low memory usage due to how it recycles unused resources or removes them if they expire. I have also included many unit tests, one of which checks for memory leaks.

A primary goal for the design of this framework is to preserve the Lua programming style. Therefore, MayronObjects should be simple to understand and pick up for Lua developers, but understanding OOP fundamentals is beneficial.

Someone once said on a similar thread post that an OOP framework for WoW addon development is over the top and unnecessary. Still, several features in this framework make me disagree with this, as outlined below:

1. MayronObjects lets you define strict typing rules easily without repeating yourself, instead of remembering to throw your errors with many assert checks at the beginning of each function. You can define a rule to declare that an object's method must take a specific type of argument, which also works for return values. This type can be a simple type (e.g., strings, numbers, tables, functions) or a complex type (blizzard widgets and classes or interfaces created from the framework). If MayronObjects detects rule violations, it will throw a typical "bad argument" or "bad return value" detailed error message. This feature has saved me many times during development.

2. MayronObjects assigns each instance a unique private instance data table, and classes can have private methods. Private data allows for strong encapsulation to ensure that other devs are using your packages correctly. Additionally, other external code cannot corrupt the instance's private data by mistake.

3. The framework provides a way of exporting and importing packages containing classes to be reused across your projects or by other addon authors. I have created some simple collection classes for reusability purposes and have published one package (Pkg-GridPanels). One day, I would love to see another addon author publish some utility package into the ecosystem.

4. MayronObjects allows you to define well-structured packages using interfaces for improved collaboration with other devs if needed. This feature has worked exceptionally well for my UI's plugin/module system. Also, as a bonus, Generic classes allow you to reuse the same classes and class logic with strict typing rules that can be modified depending on the types of data you are using.

5. You can attach attributes to methods, and MayronObjects will call these to perform pre-execution logic before calling the targetted method. Attributes can even prevent methods from being called and can modify arguments before being sent to the method. I use InCombatAttribute to prevent methods from being called if the player is in combat, but there are several use-cases for attributes where I think they would shine.

6. Having a parent base class to control the modular system I use in my UI (i.e., MayronUI) has helped me control the life-cycles of modules from a top-level perspective, which has streamlined the whole process.

These are just some of the useful things off the top of my head, but I'm sure I've missed some.
If you are interested in reading more or want to download the framework to try it out, the full documentation and download links are available at:


Thanks for reading!
MayronUI Discord communitymayronui.com

Last edited by Mayron : 12-08-20 at 10:02 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Dev Tools » MayronObjects - An OOP framework with low memory usage

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off