|
| 05 Jul 2016 03:29 AM |
What is considered 'clean' code
any examples?
also, what is considered unclean code :u |
|
|
| Report Abuse |
|
|
|
| 05 Jul 2016 03:35 AM |
not using a bunch of waits and using a single for loop
not writing out the same thing 1million times instead of a simple variable definition
using non-deprecated methods
Add 13,000 posts |
|
|
| Report Abuse |
|
|
|
| 05 Jul 2016 03:37 AM |
| clean is tabbed and commented with descriptive variable names that follow a reasonable patten. Roblox lua's casing seems to be CamelCase for objects and properties, lowerCase for variables. |
|
|
| Report Abuse |
|
|
Siarius
|
  |
| Joined: 01 Apr 2012 |
| Total Posts: 197 |
|
|
| 05 Jul 2016 03:38 AM |
Clean code:
function herro(am)
if not am == "asian" then
print(1 - 1) end
end
unclean code:
for i,v in pairs(game.Players:GetPlayers()) do if not v:WaitForChild("Asian").Value == true then print(1-1) end end
so basically clean code is whitespace, and tabbed, so it is easier to read. unclean code is where it id all compact and hard to read.
if this is what u meant by clean and unclean code. |
|
|
| Report Abuse |
|
|
| |
|
Siarius
|
  |
| Joined: 01 Apr 2012 |
| Total Posts: 197 |
|
|
| 05 Jul 2016 03:39 AM |
| @OP, reg is also right, he included capitialization for stuff. |
|
|
| Report Abuse |
|
|
|
| 05 Jul 2016 03:39 AM |
"good troll"
who
Add 13,000 posts |
|
|
| Report Abuse |
|
|
|
| 05 Jul 2016 03:40 AM |
| siarus over-exaggerated the whitespace |
|
|
| Report Abuse |
|
|
Siarius
|
  |
| Joined: 01 Apr 2012 |
| Total Posts: 197 |
|
|
| 05 Jul 2016 03:40 AM |
| @cnt, not a troll, just wrote first things that came to my mind. |
|
|
| Report Abuse |
|
|
ElectroTM
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 1135 |
|
|
| 05 Jul 2016 03:40 AM |
using functions to make everything understandable is a good way to keep your code clean.
ex: local function startRound() --Stuff end local function spawnPlayer(plr) --Stuff end local function spawnAllPlayers() for i,v in pairs(game.Players:GetPlayers())do spawnPlayer(v) end end remoteEvent.OnServerEvent:connect(function() spawn(function() startRound() spawnAllPlayers() end) end)
y-you too... |
|
|
| Report Abuse |
|
|