View Single Post
05/12/14, 11:53 AM   #52
CatoTheElder
Join Date: May 2014
Posts: 44
Originally Posted by skyraker View Post
Cato, I like your discussions and thoughts from being a profession programmer, but I agree with others that you tend to be a little terse when disagreeing with others who also claim to be professionals. With what little software development I was able to learn (since I never made it my profession), even I noticed that people do things in different ways for a variety of different reasons. And they all have their preferred methods of doing things. I would have the same attitude if someone insulted how you coded (which I believe someone did in another thread and I was a little more supportive of your response).

You talk about the problem of using OnUpdate because everything in it is called so much. The problem I ran into is that there are many functions in ESO that aren't associated with an event. Take location updates. When you run around there is nothing that can tell an addon that the player's location has changed. So, to update something that can be constantly changing like this I need to call my update function through OnUpdate. Yes, I understand that this could drain resources, but is necessary for the functionality of the addon. What would be your suggestion in such cases?
Thanks Sky. I am quite touchy when disagreeing with others who claim to be professionals, extremely so on this particular topic. There are a few reasons for my "terseness", I'll list quickly (please don't take my brevity for rudeness.) Hopefully this clears things up, and we can move on.

1) A professional programmer should know to review empirical data and reference material.
2) Programming, compilers etc. operate solely on classic logic. Typo one character, and the compiler will throw an error at you. Do what you want on your own system, but please don't publish code that will be problematic for others, and especially encourage others to do the same because "they want to". 20+ years of debugging and error testing makes it hard to be polite about programming inefficiency and errors. I do try, believe it or not.
3) This thread is about "... best practices", not "prefered methods".
4) I was banned over this topic a few years back from this site's "sister" (WoW) by the same community of admins. A few years later, the same argument is still going on. It is fairly easy to measure performance metrics for oneself. This shouldn't have lasted a month, never mind years. Which is why I asked for the end of the thread.

As for your question regarding OnUpdate() usage. This turns out to be a fairly common thing, which is quite difficult to implement. Usually, this is intentional, as it opens up a lot of potential abuse for botting. As long as zo_CallLater is available, that should be used. This will let the timing function be done in the engine, as a general rule of thumb, the more you can pass to the engine, the better.

Without that, I'd create a separate thread for the function (preventing the main thread from getting blocked), and use a time comparison to run a recursive function once every half second or so. (tweak time for performance/addon latency). Still a bit of a dirty hack though; use EVENT_PLAYER_STATUS_CHANGED and whatever other tricks you can to keep the usage as low as possible (Don't need to spam updates when the player is afk, do we?)

Hope this helps!
Cheers!
  Reply With Quote