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.Categorize by functionality
Definition; Putting classes into their folder according to their main functionality.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.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