<!--
title: Simplify code structure
domain: orchestration
topic: Code Style
language: Go
source: istio/istio
updated: 2025-07-08
url: https://awesomereviewers.com/reviewers/istio-simplify-code-structure/
-->

Prioritize code simplicity and readability by leveraging standard library functions, improving control flow patterns, and eliminating unnecessary complexity.

Key practices:
1. **Use standard library functions** instead of reinventing functionality. For example, use `strings.Join(fields, "\t")` instead of custom `joinWithTabs` functions, or `slices.Contains(slice, item)` instead of manual loops.

2. **Apply "exit early" patterns** to reduce nesting and improve readability. Structure conditionals to handle error cases or special conditions first, then continue with the main logic:
```go
// Instead of nested conditions
if condition {
    // main logic here
} else {
    return error
}

// Use exit early
if !condition {
    return error
}
// main logic here
```

3. **Eliminate superfluous code** such as redundant else clauses after return/continue statements, unnecessary variables when one suffices, and boolean literals in expressions (`if !flag` instead of `if flag == false`).

4. **Avoid unnecessary complexity** by removing redundant code after refactoring, consolidating duplicate logic, and keeping variable scope minimal.

These practices enhance code maintainability, reduce cognitive load for reviewers, and follow Go idioms for clean, readable code.
