View Single Post
04/08/14, 01:01 PM   #24
thelegendaryof
 
thelegendaryof's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 161
Originally Posted by Xrystal View Post
I can see where you are coming from and I don't negate anything you said. However.

My main reasons for doing everything in Lua is as follows:

1. Ability to create un-named frames to keep them out of the global namespace and local to the file itself.
2. Ability to at a later date allow access outside of the addon to one or more frames/tables at will with a simple function.
3. Error track ability. Lua related errors will show file name and line that the last error was noticed. XML related errors will not even mention what file let alone which element within the file is triggering the problem.

So here goes my view on Pros and Cons.

Both XML and Lua
Pros
-- Separates layout and functionality
-- Allows easier relocation of individual frames without the need to change functionality
Cons
-- Forces global naming and public access to every frame regardless to whether you wanted to or not
-- Forces unique and normally longwinded naming due to the global nature of XML structure
-- Errors are harder to identify if they are triggered in the XML and not the Lua file first.

Just Lua
Pros
-- Full control over process order
-- The ability to keep all data out of the global namespace and private to the addon
-- Allows realistic naming of variables as they are only used in your addon.
-- Errors are easier to identify as file name and line number are reported when errors occur
Cons
-- Some functionality, so far, seems to only be available inside of XML files meaning a Lua only project may not be possible.
-- Changing of layout may be somewhat more work, depending on how it was coded in the first place.

I have never said or felt that XML users were doing anything wrong, just that I felt more comfortable to use just Lua. I have no real problem using XML and Lua in my projects but I don't like the idea of having frames unnecessarily in the global table. Which at present all my frames are, and my addon still hasn't reached it's peak yet so I won't be surprised to find myself adding more frames later on for one functionality or another which will mean I will have even more frames flooding the global table needlessly. Unless of course there is a way to make un named frames with XML ? I doubt that the name field is optional if you need to access it in your lua file.
Yip absolutely valid as well. Wasn't basically directed towards you or any other advanced developer more like a general rule for the thread opener and alike. As always if you're experienced - break the rule when you feel like it 's right to do so (there 's always pros and cons).

Last edited by thelegendaryof : 04/08/14 at 01:06 PM.
  Reply With Quote