At least I know more about what to ask for this time.
With 8.0 - Blizzard introduced frame pools and they look interesting but I can’t find any examples of their use in a practical situation.
I was hoping someone had one that I could study.
At least I know more about what to ask for this time.
With 8.0 - Blizzard introduced frame pools and they look interesting but I can’t find any examples of their use in a practical situation.
I was hoping someone had one that I could study.
Blizzard created the manager for their own use. I don’t know of anyone else using them but that’s not saying much.
The Blizzard_UIWidgets addon pretty much starts with
self.widgetPools = CreateFramePoolCollection
in Blizzard_UIWidgetManager.lua
That’s the hint I was looking for, I expect.
They did announce the frame pools in the 8.0 changes announcement with some very rudimentary illustration about how it could be used.
I’m hoping it’ll save me a ton of coding with this buttons under keys under devices frame structure I need for my addon.
I plan to spend a week or so experimenting with it to see if I can make use of it.
See, this is the reason that I was looking for examples:
function SecureCapsuleGet(name)
if ( not issecure() ) then
return;
end
if ( type(contents[name]) == "table" ) then
--Segment the users
return copyTable(contents[name]);
else
return contents[name];
end
end
That’s actual code from within a chain of calls associated with Pools.lua.
Seriously?
function SecureCapsuleGet(name)
if issecure() then
if type(contents[name]) == "table" then
--Segment the users
return copyTable(contents[name])
else
return contents[name]
end
else
return
end
end
Why? Why would this be coded with that idiotic negative logic statement?
It won’t save cycles. It isn’t more clear. Adding it adds only one layer of depth to the logic structure.
Anyone out there belittling using addons needs to understand exactly how bad Blizzard’s code is and that the base game IS a collection of (mostly poorly written) addons.
Even weirder:
--Create a local version of this function just so we don't have to worry about changes
local function copyTable(tab)
local copy = {};
for k, v in pairs(tab) do
if ( type(v) == "table" ) then
copy[k] = copyTable(v);
else
copy[k] = v;
end
end
return copy;
end
That’s a function in SecureCapsule.lua.
function CopyTable(settings)
local copy = {};
for k, v in pairs(settings) do
if ( type(v) == "table" ) then
copy[k] = CopyTable(v);
else
copy[k] = v;
end
end
return copy;
end
That’s the version from Util.lua that apparently the creator of SecureCapsule.lua was worried would change and upset his code.
That function was added in build 17930 and released on February 19th, 2014 and hasn’t changed since.
So SecureCapsule’s creator created what he calls a “local copy” of CopyTable (but renamed to copyTable) out of some concern that an utterly stable function that hasn’t changed in the more than five years since it first showed up in Util.lua would be altered.
Decision making like that and the utter failure of whatever code review process Blizzard has in place is what makes me worry for the future of this game.
This is gonna be a long couple of weeks if the path I’m chasing down is all written this poorly.
If I were feeling at all cynical I might say they are possibly a previous WoW addon author but…
Maybe I’m misunderstanding what these pools are for, but it seems from the little I’ve seen that they establish relationships between frames based on both explicit definitions and potentially variable parameters.
If I have that correct, these are exactly what I need for my project.
Essentially I have an on-screen image of an input device (let’s use an Orbweaver Chroma for an example) on which there are then images of each Key and in each Key is a non-interactive Button.
I think what the pools will allow me to do is define a “Device” as being a frame that contains an array of “Keys” each of which contains a “Button” (my use of that term, not Blizzard’s because it’s not clickable but it does have layers of displays that mimic much of what’s going on with actual buttons).
If I were defining only one device, this wouldn’t be optimal - the overhead from pools would exceed the benefit of using them.
But I have a plug-in system whereby anyone can define a “Device” and with that plug-in system the pools seem to come into their own (if I have a clear understanding of what they are for).
On my own PC I have three devices defined (at an abstract level - not implemented yet) - my numpad, a G13, and a Redragon M990 mouse. My GF’s PC I have another two devices to define - a flight stick (yeah, complicated - she only has one hand to work with) and a G600MMO mouse.
But I have in mind to make this universal enough that anything from a complete on-screen (very small) keyboard could be defined to individual puff-n-sip or foot pedal switches (for the profoundly disabled).
If I can define a “Device” like this and parameterize SOME of its characteristics (like the dimensions of the bounding frame for its image) and also define the “Key” array in a way that will allow me to likewise and the single “Button” associated with that “Key” then I think this might save me a lot of otherwise redundant coding.
Added:
Fizzie, I’d agree with you, but I’ve seen too much just terrible code in there over the years to believe this is anything other than a cultural failure within Blizzard to attract quality coders, train the ones they have to work to some sort of rational standards, and/or oversee any sort of code review prior to implementation.
The example I gave above - if they had stored the return value of issecure() somewhere BEFORE that logic branch and it was far more likely that the function would test as NOT being secure, it MIGHT, just MIGHT have made sense to test the negative condition first, but even that would have been better done by storing and using the secure state of the function this way:
local isInsecure = not issecure(functionName)
if isInsecure then
return
else
do the rest of the function
end
That guideline about not coding “negative logic” exists because it makes maintenance and troubleshooting simpler.
That’s not opinion. That’s hard-earned field knowledge learned over decades of time.
I’m already at GWOT here or I’d link the psych studies that prove that people are far more likely to misread a negative condition than a positive one in when parsing out logic statements.
Nonsense like this goes all the way back to the first release version of WoW.
It’s 100% indicative of “The Linux Disease” (that syndrome that drives coders to create deliberately obtuse code because ‘if it was hard to write, it should be hard to read’).
Of course the Linux Disease isn’t limited to code written in or for the Linux environment, but it surfaces there more than anywhere else I’ve seen outside of hard-core telecommuncations company use of C and C++.
/rantoff
Summary of Cast/Use/CastSequence/CastRandom/UseRandom Idiocy