Code formatting

You could argue to the contrary. If you name functions and variables correctly, there’s no need for extra documentation. Code should be understandable by itself, self-documented. Don't Write Comments - YouTube

2 Likes

(post marked for deletion for privacy reasons)

You forgor to add an extra 5 new lines for no good reason!

You can’t just do game.Players.LocalPlayer? I guess everybody has a different style.

But seriously, this will hopefully help new scripters understand the conventions. Thanks!

1 Like

Both, both is good.

An identifier / function name should explain what something is, a comment should be used to explain why something is done.

Generally speaking, not using comments at all can reduce the overall cohesion of your program, and therefore make it less understandable, navigable, and debuggable.

1 Like

The whole point of me putting that section there was to illustrate that if you for some reason couldn’t format your code correctly, simply use comments. Even if you do format your code correctly, you still need to use comments, because that documents the use of it.

Yes, but in my previous post someone told me that it’s “good practice” to do :GetService() instead, so now I’m starting to realize that people are always going to have a problem with your code however you write it.

Here’s the post:

It is good practice. I always use :GetService() to avoid issues if ever something is renamed. For instance, I could at any point rename Workspace to something else. Roblox does not prohibit the renaming of services within games. :GetService() will always be consistent.

1 Like

If you clearly convey the meaning of the identifier, then there’s no need for comments. An exaggerated example:

function CreateExplodingPart()

function CreatePart() // Creates a new part that explodes

I don’t think you’re getting the point what he said. It’s always good practice in any form of skill to make sure. Anytime, making sure is always a good thing to do. So there’s nothing wrong with adding comments. What if the reader doesn’t know how to code? And they don’t know what a function is?

1 Like

99% of the time someone that doesn’t know how to code wouldn’t be looking through code.

This is very untrue, and I’m just going to let someone else explain that for you.

It won’t be renamed. I don’t know why people hold on to that myth.
I only use :GetService() on services whose name is not their ClassName, such as game["Run Service"].

1 Like

The same principal goes for this argument. If you can make sure, then make sure. There’s nothing wrong with it.

image
As I was saying.

1 Like

If you’re worried about a virus renaming services, then you can immediately notice because the game won’t work anymore. If an exploiter renames services locally, then their game won’t work.
So what’s the point of worrying??

Did you read this? This is very important, by the way.

Future proofing your code?

Which can be countered by simply using GetService

1 Like

Any sources on this?

characters

I noticed that this tutorial teaches us bad programming practices in general. A notable example is not making services plural if they are, and using multiple get service calls.

Here’s a good video talking about some of these things:

Also, you should use task.wait as it’s more accurate than just wait.