#Is it ok to structure your code like this?

1 messages · Page 1 of 1 (latest)

bronze path
#

I’ve been struggling with creating multiple instances in a script, especially when working with GUIs. After a lot of trial and error, I found a structure that seems both promising and easier for my future self to understand.

However, I’m not sure if it’s optimal to use 'do ... end' to separate blocks, nor create lots of nested tables.

#
 ClientDevGui  ▼  {
                    ["gui"] =  ▼  {
                       ["base"] = DeveloperGui,
                       ["root"] =  ▼  {
                          ["base"] = Root,
                          ["list"] =  ▼  {
                             ["base"] = list,
                             ["that"] = "*** cycle table reference detected ***",
                             ["updatePadding"] = "function"
                          },
                          ["main"] =  ▼  {
                             ["base"] = Main,
                             ["that"] = "*** cycle table reference detected ***",
                             ["updateSize"] = "function"
                          },
                          ["tab"] =  ▼  {
                             ["base"] = Tab,
                             ["list"] =  ▼  {
                                ["base"] = List,
                                ["that"] = "*** cycle table reference detected ***",
                                ["updatePadding"] = "function"
                             },
                             ["that"] = "*** cycle table reference detected ***",
                             ["updateScrollbarThickness"] = "function",
                             ["updateSize"] = "function"
                          },
                          ["that"] = "*** cycle table reference detected ***"
                       },
                       ["that"] = "*** cycle table reference detected ***"
                    }
                 }
glossy rapids
#

Of course it is fine. Though your method somewhat leans towords the OOP paradigm that most devs follow for cases like yours. I'd suggest you adopt that style completely. It'd look smth like