Organization 101

Organization 101

As a UI designer and a coder in Roblox, I do find out organizing can ensure my efficiency and it does make the final product better, for the consumers.

Here’s a few standard organizing methods, for classes and instances.

  • Categorize by classes
  • Categorize by functionality (What this class used for)
  • Both

Categorize by classes

Definition; Putting every classes into their own folder with the class name. For example, Gui goes to the folder Gui.

image

Categorize by functionality

Definition; Putting classes into their folder according to their main functionality.

image

Both of the methods above has their own pros and cons, such as the categorize by classes method may confuse consumers due to the fact of the renaming method for the classes, the categorize by functionality may look a bit messy if there’s other classes such as script.

Both

Definition; Combining both methods into one, aka first categorize class, then categorize functionality.

image

Organizing for scripts

I’ve realised that this organisation method for script is a terrible coding practice in terms of size, as 1 character counts as 1 byte, separators for different contexts will just make your script much bloated, rather than being organised. Skip 1-2 lines to separate different contexts isntead

This actually does exist, for scripts. They will make code much cleaner, as you will categorize them by the methods (Events, Functions, Variables etc)

For me, I will be having this layout for all scripts;

--[[
    ScriptName.lua
    Created by Nakogls
    Created at XX/XX/XXXX

    This script is used to...

    Table of content;
    - Variables
    - Functions
    - Events
    - Startup
-]]

-- Variables
local Something = Something

-- Functions
function Something()

end

-- Events
Something:GetPropertyChangedSignal("Something"):Connect(function()

end)

-- Startup
repeat wait() until game:GetService("ContentProvider").RequestQueueSize == 0
Something()

As you can see, this looks better than without any organization, and is more informative, telling the consumer what this script does, as well as making the script much easier to inspect/edit.

Now, let’s take a look of the one without any organization;

local Something1 = Something1
function Something()

end
Something1:GetPropertyChangedSignal("Something"):Connect(function()

end)
repeat wait() until game:GetService("ContentProvider").RequestQueueSize == 0
Something()

Yuck, looks so messy, if there’s more content in the scripts.

tldr: try to sort your script in a nicer way, such as putting variables at top, and then functions in center, and events/first-run code at bottom

Glossary

Before you start doing your commission, or making stuff in Studio, make sure to use organization, no matter how massive the item is. As it can improve readability for scripts, and will be much cleaner, making yourself satisfied.

Got other organizing methods?

You should let us know how you organize, maybe it will be better than the one I've mentioned.
33 Likes

Pro Tip: Roblox have a pretty good spec for writing Lua. It’s used by them for all internal products.

https://roblox.github.io/lua-style-guide/

10 Likes