Thread: ZO_Object
View Single Post
07/07/15, 08:38 PM   #11
XanDDemoX
AddOn Author - Click to view addons
Join Date: May 2015
Posts: 28
Originally Posted by Atropos View Post
I understand the difference between functional and OO. I was trying to encourage some discussion to quantify the advantages of using objectification in actual ESO addon applications.

For example, the following thought exercise:

Suppose you have 20 objects in a table containing data that updates several times per second. You want to render this data in a way that updates every 10th of a second (10x per second). Two ways to approach the problem might be:

Functional - Have a single OnUpdate function which loops over the elements of the table and executes some function on each element sequentially.

Object Oriented - Create each element of the table as an object that inherits its own methods and updating function. Each child object updates itself.

Is one approach more efficient (in terms of performance)? It's generally not clear to me whether there is a gain from trying to use object inheritance in LUA other than simply making it easier to think about certain types of problems.
In my opinion the advantages and disadvantages of either approach aren't any different for ESO addons than they are for any other application.

When your talking performance you can only quantify different solutions to see which is the fastest.

I suppose something to consider is that in a class hierarchy when attempting to resolve the value of a key, each table must be searched until the value for a specific key is found.

Therefore as the height of the hierarchy grows, so will the number of tables to potentially search for the matching value of a particular key. Which of course will always be extra overhead on top of searching just a single table to resolve a function address or other value.
  Reply With Quote