Code Readability

Goes over naming conventions and organized code.

by Aaronp7superstar

Author Avatar

image|100x100, 160%

#| Tutorial | Code Readability | Beginner |

NOTE: This will be going over naming conventions, organized diagrams, and reusable code. All of these will be defined in the Tutorial. Vocabulary for highlighted words will be at the bottom of the Tutorial.

Learning Target: I can correctly organize my code in a way that is understandable and readable to others.

Separator|100x100, 160%

##Why should I make my Code Readable?

Code readablility can help readers understand what your code does faster. If you are working in a studio with multiple scripters or developers. These people may want to modify or understand how the code works. If they catch a bug or want to add a new feature it would be really helpful if they could understand the code.

Your code should:

Obviously, creating readable code takes more effort than quickly written code.

Separator|100x100, 160% ##Naming Conventions

What is a naming Convention?

A naming convention is a rule for how you name various files, folder, objects, variables. functions, etc. A naming convention can help make your code for understandable and discoverable when used consistently.

Common Naming Conventions

Pascal Case

Pascal case is basically the same thing as Camel case except every word begins with a capital letter.

Snake Case

Snake case is normally used in C-style languages. It seperates the words with and "_" and normally is used to denote a constant.

Applying the naming conventions together

Some developers also use two different naming conventions together. Functions will use Pascal case and variables will use Camel case.


local exampleString = "Interesting String"

function RemoveSpaces(stringToSplit:string)
	return stringToSplit:gsub(" ","")

Separator|100x100, 160% ##Code Organization

Organizing your code with notes can help readers understands what section of your code does what. You could make a section of your script for variables, and another for functions. You could even list different types of variables separately. Putting an overview at the top of your code to explain the purpose of the entire script can be helpful as well.

You can separate different types of variables and functions with notes. you can even make it fancy with little arrow shapes.

If you have a time value, you could put a note next to it that says if it is in seconds, minute, hours, etc.


CREATOR: ExampleUsername

This code is used to demonstrate how users can, put notes on their code, make it
more readable to users, create an overview, and organize their code.

--[[ |> Services <| ]]--

local replicatedStorage = game:GetService("ReplicatedStorage")
local httpService = game:GetService("HttpService")
local dataStoreService = game:GetService("DataStoreService")

--[[ |> Objects <| ]]--

local spawnLocation = workspace.SpawnLocation

--[[ |> Values <| ]]--

local debounce = false
local totalMatchTime = 100 -- In seconds

--[[ |> Setup Functions <| ]]--

function SetupGame(stuff here)
	stuff here

--[[ |> Match Functions <| ]]--

function RunGame(stuff here)
	stuff here

Separator|100x100, 160% #Vocabulary

scripter (computing) - A person who writes or users a programming language. A programmer.

consistent - Acting or done the same way over time. Example, "The parents are being consistent and firm in their reactions."

denote (computing) - Stand as a name or a symbol for. Example, "The level of output per film, denote by X."

Separator|100x100, 160%

Learning Target: I can correctly organize my code in a way that is understandable and readable to others.

image|100x100, 160%

image|100x100, 160%

View in-game to comment, award, and more!