Closed SafeteeWoW closed 3 years ago
I want to manage v3 code in the following ways. Each item I have mentioned should be in a separate file.
Item
: Provide apis to cache and query item info.PlayerInfo
: Provide apis to cache and query player info.Loot
: Provide apis to cache and query loot info.Communication
: Interface to send and receive addon messages.Serializer
: Serialize lua table better than AceSerializerVotingFrame
LootFrame
SessionFrame
OptionFrame
SyncFrame
VersionCheck
LootHistory
TradeFrame
(planned)I am wondering how should I implement an API file. There are several options:
ItemAPI=LibStub:NewLibrary
: The issue is that this exports the internal api to the outside world, which I don't like.ItemAPI=AceAddon;NewModule
: This is a standard way, but I don't like them to be declared in the same way as MODULE._G.RCAPI.ItemAPI = {}
. This is the way I prefer the most currently.LibStub:NewLibrary
should only be used for separate libraries that can be shared between addons - RCSerializer might be a candidate for this, if you intent to make it public - otherwise it shouldn't be used.AceAddon:NewModule
should only be used when something needs the inherited AceAddon
functions (modules are in fact treated as separate addon objects, with a reference to the core). I used this for the "modules" to separate them cleanly and to give them access to the db object. I don't think it's a good idea to use it for API/utility functions.RCLootCouncil.Item
, or maybe RCLootCouncil.API.Item
to really separate it, but I'm not sure that extra table really is needed.Next to consider is objects. When you're talking about API's, I'm thinking somewhat simple functions. For example, consider handling an item, with API I understand something like:
local itemName = RCLootCouncil.Item:GetItemName(itemLink)
local ilvl = RCLootCouncil.Item:GetItemLevel(itemLink)
I'd very much like a more object oriented approach, so that the following is possible:
local item = RCLootCouncil.Item:GetItem(itemLink)
-- Either this:
local itemName = item.name
-- or this:
local itemName = item:GetName()
local ilvl = item.ilvl or item:GetItemLevel()
Furthermore I think session
should be added to your list of APIs, but otherwise I agree with you.
i am working on the pure lua deflate compression,( google Rfc1951 for spec ). Current result is twice slower than libcompress, but 30% smaller.(not fullt tuned yet ) I will first finalize serializer and compressor, to be released as standalone lib, as the design of those must be frozen at the first release of v3 for backward compatibility reasons.
Another thing I'd to change is the current award system. The amount of functions handling this has become too huge and segregated: rightClickMenu > PopupYes > ML:Award > (several paths, usually ML:CanGiveLoot) > ML:GiveLoot > Callback1 > awardSucces > Callback2 (potentionally another callback) > ML:TrackAndLogLoot > registerAndAnnounce > HasAllItemsBeenAwarded > potentially more
i.e. at least 10 different functions, most of them with several fail states.
The biggest issue is, I recently discovered that doing "Award Later" on the last item in a session (probably not only the last) wouldn't end the session nor register anything useful that could end the session. I spend almost an hour trying to track through every step to identify where the fault was, and where it could be implemented (basically there's a missing variable or a complicated check of ml.lootTable.baggedEntry/baggedInSession
). As per my roadmap in #116, this is not critical enough to warrant a change until after 3.0 though.
Hope you can first work on new communication protocol, which transmit as less data as possible. For compatibility reasons, the protocol needs to be finalized before v3, which needs to be done first.l
There are lots of coding structure problems in v2.x
I have signed up TradeSkillMaster4 Beta and read its blog, trying to figure out the solution. See also https://blog.tradeskillmaster.com/classes/