You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
- 5"Since any IDE will render comments in a different colour, having a blank line and a single short comment at the top of a block of code can help the eye spot the logical sections." So would whitespace, and that would be easier to write, maintain, and navigate by cursor.Flater– Flater2024-06-13 04:26:12 +00:00Commented Jun 13, 2024 at 4:26
- 1@Flater "So would whitespace" - well, yes, that's why I explicitly said "a blank line and a short comment". Providing visual cues - including both whitespace and comments - is a useful technique for improving code readability, even if the question is a terrible example of how to do that correctly.Simon Geard– Simon Geard2024-06-14 00:31:13 +00:00Commented Jun 14, 2024 at 0:31
- As an example, I typically separate sections of code in my file with 5 lines. In order: a blank line, a comment line with no text, a comment line with the section title, a comment line with no text, and another blank line. This is lightweight to maintain, and pops out sufficiently in the file outline in the IDE to quickly jump from section to section.Matthieu M.– Matthieu M.2024-06-15 10:36:47 +00:00Commented Jun 15, 2024 at 10:36
- @MatthieuM. That's a bit too much whitespace for my taste - in general I wouldn't want more than one blank line and one comment - but not unreasonable.Simon Geard– Simon Geard2024-06-16 20:41:58 +00:00Commented Jun 16, 2024 at 20:41
- @SimonGeard: I think it depends what you're commenting for. As I mentioned I use those 5 lines as "section separators", and my files typically have only one such separator (between the public section first, and the implementation section second), so 5 lines is fine... and really helps pinpointing it in the outline. For doc comments on methods, I don't "waste" lines.Matthieu M.– Matthieu M.2024-06-17 07:48:18 +00:00Commented Jun 17, 2024 at 7:48
Add a comment |
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
- create code fences with backticks ` or tildes ~ ```
like so
``` - add language identifier to highlight code ```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible) <https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. design-patterns), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you
lang-java