Closed aaronfranke closed 5 years ago
We've used both at GDquest, but use 2 now. It makes the code a lot easier to read, as you may have empty lines inside of methods or between variable definitions. It's instantly clear that 2 line gaps separate methods. From the GDquest gdscript guidelines:
Always leave 2 blanks lines between methods to visually distinguish them and other code blocks.
The Python pep8 recommends 2 lines between functions or classes inside python modules for the same reason (and inside a class 1 line between methods). To me, it has a practical benefit. Especially for people reading the docs, the clearer and the more visually organized, the easier it is to read.
I agree with recommending 2 blank lines between methods. My projects currently separate methods with one blank line only, but I'll gladly switch to 2 if this recommendation gets added to the style guide.
Like in Python, we should also advise using only one consecutive blank line in a method body.
What about before methods?
var x
func test():
vs
var x
func test():
In many GDScript projects, I have seen several ways to separate functions. Sometimes one line:
But sometimes two:
I have also seen functions separated by 3 or more lines. I think that we should probably have no more than 2, but what should the policy be between 1 and 2 lines? Situationally? User discretion? Encourage one over the other? Disallow one or the other entirely?
We should probably decide on something and put it in the style guide.