Coding Style GuideTopic 5 of 5~5 min

White Space

Developer Removes All Whitespace to 'Save Bytes'; Code Review Takes 6 Hours

Illustration comparing code with proper whitespace as a well-organized garden vs code without whitespace as an overgrown jungle

White space is not wasted space. It's breathing room for your code. Just as paragraphs make text readable, strategic blank lines and spaces make code scannable.

White Space Rules

Spaces around operators

Good:x = y + z;
Bad:x=y+z;

Space after commas

Good:Method(a, b, c)
Bad:Method(a,b,c)

Blank lines between methods

Separate methods with exactly one blank line. No more, no less.

No trailing whitespace

Lines should not end with spaces or tabs. Configure your editor to remove them.

Quick Check

What is the purpose of blank lines between methods in a class?

Course Summary

  • File Organization: One class per file, named to match the class.
  • Indentation: Use tabs consistently, one level per block.
  • Naming: PascalCase for public, camelCase for private, descriptive always.
  • Braces: Always use them, even for single statements.
  • White Space: Use it strategically to improve readability.

Download Cheat Sheet

File organization, naming conventions, indentation rules, and statement guidelines