banner

Good code is not only code that works. Good code is code that other engineers can understand, review, modify, and maintain.

As software systems grow, consistency becomes increasingly important.

A small project can survive different naming conventions, formatting preferences, and programming styles. A codebase maintained by dozens, hundreds, or thousands of engineers cannot.

This is where style guides become valuable.

One of the best collections of real-world engineering conventions is the Google Style Guides project.


🧭 1. What Is a Style Guide?

A style guide is a collection of conventions describing how code should be written within a project or organization.

At first glance, this may sound like formatting:

1
2
3
camelCase vs snake_case
tabs vs spaces
80 vs 100 character lines

But engineering style goes much further.

A style guide may define conventions around:

  • Naming
  • Formatting
  • Imports
  • Comments
  • Error handling
  • Language features
  • APIs
  • Global state
  • Exceptions
  • Type usage
  • Documentation
  • File organization

The goal is not to determine the one objectively perfect way to write software.

The goal is to make the codebase consistent.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
Many developers
Shared conventions
Consistent code
Easier reviews
Easier maintenance

Consistency reduces the number of unnecessary decisions engineers need to make every day.


🏗️ 2. Why Style Matters at Scale

Imagine two developers writing the same functionality.

Developer A writes:

1
2
3
const getUserById = (id: string): User | undefined => {
    return users.find((user) => user.id === id)
}

Developer B writes:

1
2
3
function find_user(ID: string) {
    return users.find(x => x.id == ID);
}

Both implementations may work.

But across thousands of files, inconsistent approaches accumulate.

You eventually get:

1
2
3
4
5
6
getUser()
find_user()
FindUser()
retrieveUser()
fetch_user()
userLookup()

The problem is no longer syntax.

The problem is cognitive load.

Every engineer must continuously interpret different conventions before understanding the actual business logic.

A shared style guide removes much of that noise.


🧠 3. Readability Is an Engineering Property

Readable code is easier to:

  • Review
  • Debug
  • Test
  • Refactor
  • Extend
  • Operate
  • Transfer between teams

This becomes especially important in long-lived systems.

Code may be written once but read hundreds of times.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
Writing code
Code Review
Maintenance
Debugging
Refactoring
New Features

The original author may eventually leave the project.

The code remains.

That is why optimizing exclusively for the person writing the code is usually the wrong trade-off.

Optimize for the next engineer reading it.


🌐 4. Google Style Guides

Google publishes a collection of style guides used for Google-originated open-source projects.

The main collection is available here:

Google Style Guides

At the time of writing, the collection includes guides for technologies such as:

Language / TechnologyStyle Guide
C++Google C++ Style Guide
C#Google C# Style Guide
GoGoogle Go Style Guide
HTML/CSSGoogle HTML/CSS Style Guide
JavaGoogle Java Style Guide
JavaScriptGoogle JavaScript Style Guide
JSONGoogle JSON Style Guide
MarkdownGoogle Markdown Style Guide
PythonGoogle Python Style Guide
ShellGoogle Shell Style Guide
TypeScriptGoogle TypeScript Style Guide

There are also guides for technologies including Objective-C, R, Swift, Common Lisp, AngularJS, and Vim script.

This makes the repository useful even if your organization uses multiple programming languages.


🐹 5. Google Go Style Guide

The Google Go Style Guide is particularly interesting because it separates guidance into several layers:

1
2
3
4
5
Go Style
├── Style Guide
├── Style Decisions
└── Best Practices

The main guide defines foundational principles for writing readable and idiomatic Go.

Google summarizes readable Go around several important properties:

  1. Clarity
  2. Simplicity
  3. Concision
  4. Maintainability
  5. Consistency

That ordering matters.

Clever code is not necessarily good code.

For example:

1
2
3
4
5
6
7
8
9
func findUser(users []User, id string) *User {
    for i := range users {
        if users[i].ID == id {
            return &users[i]
        }
    }

    return nil
}

This code is boring.

That is often a compliment.

Its behavior is immediately obvious.

🧩 Takeaway

Prefer code that another engineer can understand immediately over code that demonstrates how clever the author is.


🐍 6. Google Python Style Guide

The Google Python Style Guide covers both Python language usage and coding style.

Topics include:

  • Imports
  • Packages
  • Exceptions
  • Mutable global state
  • Comprehensions
  • Generators
  • Lambda functions
  • Decorators
  • Threading
  • Type annotations
  • Naming
  • Comments
  • Documentation

For example, imports should remain explicit and understandable.

Prefer:

1
2
3
4
import os
import sys

from application.services import user_service

over code that makes dependencies difficult to identify:

1
from application.services import *

Explicit dependencies make code easier to navigate and analyze.

🧠 Takeaway

Python makes it very easy to write concise code.

That does not mean maximum concision should always be the goal.

Readable Python is usually better than clever Python.


☕ 7. Google Java Style Guide

The Google Java Style Guide defines Google’s coding standards for Java source code.

It covers areas such as:

  • Source file structure
  • Formatting
  • Braces
  • Line wrapping
  • Naming
  • Imports
  • Comments
  • Javadoc

A simple naming example:

1
2
3
4
5
6
7
8
class UserService {

    private final UserRepository userRepository;

    UserService(UserRepository userRepository) {
        this.userRepository = userRepository;
    }
}

Consistent naming allows developers to identify concepts quickly.

1
2
3
4
UserService       → type
userRepository    → field
findUser()        → method
MAX_RETRIES       → constant

Naming conventions act as visual metadata for the reader.


🟦 8. Google TypeScript Style Guide

The Google TypeScript Style Guide is especially useful for large TypeScript codebases.

TypeScript provides a very powerful type system.

That power can improve maintainability — but it can also make a codebase unnecessarily complicated when abstractions are overused.

A readable type:

1
2
3
4
5
type User = {
    id: string
    name: string
    email: string
}

is usually preferable to introducing unnecessary generic machinery when the problem does not require it.

The same principle applies to functions.

Prefer:

1
2
3
4
5
6
function findUser(
    users: User[],
    id: string,
): User | undefined {
    return users.find((user) => user.id === id)
}

over abstractions that force the reader to decode the type system before understanding the business logic.

🧠 Takeaway

Use TypeScript’s type system to clarify intent, not to demonstrate type-system sophistication.


⚙️ 9. Google JavaScript Style Guide

The Google JavaScript Style Guide provides conventions for writing predictable JavaScript.

One simple example is variable declaration.

Prefer const by default:

1
const user = getUser()

Use let when reassignment is required:

1
2
3
4
5
let retries = 0

while (retries < 3) {
    retries++
}

Avoid unnecessary mutable state.

The difference may look small, but conventions like this communicate intent.

When a developer sees:

1
const config = loadConfig()

they immediately know the variable will not be reassigned.

Style becomes part of the communication between developers.


🖥️ 10. Google Shell Style Guide

Shell scripts often begin small:

1
2
3
#!/bin/bash

go test ./...

Then someone adds deployment logic.

Then retries.

Then configuration.

Then error handling.

Then environment detection.

Six months later:

1
2
deploy.sh
  1,847 lines

The Google Shell Style Guide provides guidance on areas including:

  • Shell selection
  • File structure
  • Comments
  • Formatting
  • Quoting
  • Variables
  • Functions
  • Command execution

But one of the most valuable lessons is architectural:

Shell should remain simple.

When shell logic becomes complicated, consider moving the functionality into a more structured programming language.

🧩 Rule of Thumb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
Small automation
    Shell
Complex business logic?
  ┌───┴───┐
  │       │
 No      Yes
  │       │
Shell   Go/Python/etc.

Shell is excellent glue.

It is rarely an ideal application architecture.


📝 11. Google Markdown Style Guide

Style guides are not limited to source code.

Documentation benefits from consistency too.

The Google Markdown Style Guide covers topics including:

  • Headings
  • Lists
  • Code blocks
  • Links
  • Tables
  • Document structure
  • Line length
  • Markdown vs HTML

For example, fenced code blocks should specify their language:

1
2
3
4
5
```go
func main() {
    fmt.Println("Hello")
}
```

instead of:

1
2
3
4
5
```
func main() {
    fmt.Println("Hello")
}
```

This improves syntax highlighting and makes the document easier for tools to process.

Documentation is part of the codebase.

Treat it accordingly.


🏷️ 12. Naming Is Architecture at the Smallest Scale

One recurring theme across style guides is naming.

Compare:

1
function process(x: any): any

with:

1
2
3
function normalizeDeviceSettings(
    settings: DeviceSettings,
): NormalizedDeviceSettings

The second function communicates considerably more information.

Good naming reduces the amount of documentation required because the code itself communicates intent.

Consider:

1
2
3
4
5
6
7
x
data
obj
tmp
manager
helper
util

These names often tell the reader very little.

Compare them with:

1
2
3
4
5
6
deviceSettings
regionalClient
vaultConfiguration
retryDelay
requestValidator
locationRepository

Names are one of the cheapest forms of documentation available.


🤝 13. Style Guides Improve Code Reviews

Without agreed conventions, code reviews can become debates about personal preferences.

1
2
3
4
5
6
7
8
Reviewer A:
"I prefer this naming style."

Reviewer B:
"I prefer another style."

Author:
"I like mine."

That is not a productive engineering discussion.

With an agreed style guide:

1
2
3
4
5
Does this follow the project's conventions?
        ├── Yes → continue review
        └── No  → fix automatically or reference the rule

Reviewers can focus on things that matter more:

  • Correctness
  • Architecture
  • Security
  • Performance
  • Tests
  • Failure scenarios
  • API contracts
  • Maintainability

This is one of the biggest practical advantages of adopting a style guide.

It removes low-value arguments from code reviews.


🤖 14. Automate Everything You Can

A style rule that can be enforced automatically usually should be.

Humans are bad at repeatedly checking mechanical rules.

Computers are excellent at it.

A typical pipeline may look like:

flowchart LR
    A[Developer] --> B[Formatter]
    B --> C[Linter]
    C --> D[Static Analysis]
    D --> E[Tests]
    E --> F[Code Review]
    F --> G[Merge]

    style A fill:#42a5f5,stroke:#1e88e5,color:#fff
    style B fill:#66bb6a,stroke:#2e7d32,color:#fff
    style C fill:#ffa726,stroke:#ef6c00,color:#fff
    style D fill:#ab47bc,stroke:#6a1b9a,color:#fff
    style E fill:#29b6f6,stroke:#0288d1,color:#fff
    style F fill:#fdd835,stroke:#f57f17,color:#000
    style G fill:#00bfa5,stroke:#00695c,color:#fff

Examples:

Go

1
2
3
4
gofmt
goimports
go vet
golangci-lint

Python

1
2
3
black
ruff
mypy

TypeScript / JavaScript

1
2
3
prettier
eslint
tsc

The exact tools matter less than the principle:

Do not make humans enforce rules that machines can enforce reliably.


🧱 15. Style Guide vs Formatter vs Linter

These concepts are related but different.

ToolResponsibility
Style GuideDefines conventions
FormatterAutomatically formats source code
LinterDetects suspicious or non-compliant patterns
Type CheckerVerifies type correctness
Static AnalyzerDetects deeper quality/security issues
Code ReviewEvaluates design, correctness, and maintainability

Think of them as layers:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
Style Guide
Formatter
Linter
Type Checker
Static Analysis
Human Review

Each layer removes a class of problems before the next layer needs to deal with them.


🧩 16. Should You Follow Google Style Exactly?

Not necessarily.

Google’s engineering environment is not your engineering environment.

Your project may have:

  • Different tooling
  • Different frameworks
  • Different deployment models
  • Different historical conventions
  • Different team preferences
  • Different compatibility requirements

A style guide should support engineering work rather than become dogma.

A good approach is:

1
2
3
4
5
6
7
8
9
Industry conventions
        +
Language conventions
        +
Google guidance
        +
Team experience
Project Style Guide

For example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Project Style Guide

Base conventions:
- Google TypeScript Style Guide

Project decisions:
- Use 4-space indentation
- Prefer `type` over `interface`
- Prefer functional modules
- Use explicit Result<T, E> for expected failures
- No console.log in production code
- ESLint must pass with zero warnings

Now the team has a clear baseline while retaining conventions specific to the project.


⚖️ 17. Consistency Beats Personal Preference

Developers naturally develop preferences.

1
2
3
4
5
tabs vs spaces
type vs interface
single vs double quotes
early return vs nested conditions
100 vs 120 character lines

Some choices matter architecturally.

Many do not.

If either approach is reasonable, consistency often provides more value than endlessly searching for the theoretically perfect convention.

1
2
3
4
5
Perfect style

Consistent style

A codebase should feel as though it was written by one engineering team, not by fifty unrelated individuals.


🚫 18. Don’t Turn Style Into Dogma

Style guides are tools.

They are not laws of physics.

There will always be situations where following a rule literally makes the code worse.

The correct priority is usually:

1
2
3
4
5
6
7
8
9
Correctness
Clarity
Maintainability
Consistency
Personal preference

If a convention actively harms clarity, discuss it with the team.

Then either make an explicit exception or improve the convention.

What you should avoid is silently creating a different style in every file.


🚀 19. A Practical Team Workflow

A simple engineering workflow might look like this:

Step 1 — Choose a baseline

For example:

1
2
3
4
Go          → Google Go Style Guide
Python      → Google Python Style Guide
Java        → Google Java Style Guide
TypeScript  → Google TypeScript Style Guide

Step 2 — Document project-specific decisions

Create something like:

1
2
3
CONTRIBUTING.md
STYLE_GUIDE.md
docs/development/style-guide.md

Step 3 — Configure automation

1
2
3
4
5
6
7
formatter
    +
linter
    +
type checker
    +
static analysis

Step 4 — Run checks locally

Developers should receive feedback before pushing code.

Step 5 — Enforce the same checks in CI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
git push
CI
   ├── format
   ├── lint
   ├── typecheck
   ├── test
   └── static analysis

Step 6 — Keep human review focused on engineering

Reviewers should spend their time asking:

1
2
3
4
5
6
7
8
9
Is the implementation correct?

Is the architecture appropriate?

Are failure scenarios covered?

Is the code understandable?

Can we maintain this in two years?

Not:

1
Should there be a blank line here?

🧠 20. The Bigger Lesson

The most valuable lesson from Google’s style guides is not any individual rule.

It is the idea that software engineering is collaborative communication.

Source code communicates with:

  • The compiler
  • Your teammates
  • Reviewers
  • Future maintainers
  • Operations engineers
  • Your future self

The compiler only needs the code to be valid.

Humans need much more.

1
2
3
4
5
6
7
                Source Code
        ┌───────────┼───────────┐
        ▼           ▼           ▼
     Compiler    Teammates    Future You
        │           │           │
    Correctness  Readability  Maintainability

A good style guide optimizes for all three.


🙌 Conclusion

Google’s Style Guides are an excellent reference for engineers who want to build consistent, readable, and maintainable codebases.

You do not need to adopt every rule.

You should understand the principle behind them:

A shared codebase needs shared conventions.

Choose sensible defaults.

Automate what can be automated.

Document project-specific decisions.

Keep code reviews focused on engineering rather than formatting preferences.

And above all:

Write code for the engineer who will have to understand it next.


🔗 Resources


🚀 Follow me on norbix.dev for more insights on Go, TypeScript, Python, AI, system design, and software engineering.