RU

Functional Patterns

Functional programming patterns: pure functions, immutability, composition.

Details

Language / Topic
rubyRuby
Category
Style Guide

Rules

balanced
- Prefer pure functions: given the same inputs, always return the same output with no side effects.
- Use immutable data structures; avoid mutating variables or objects after creation.
- Favor function composition and pipelines over deeply nested logic.
- Use higher-order functions (map, filter, reduce) instead of manual loops for collection transformations.
- Separate side effects (I/O, network, state) from pure computation; push effects to the edges of your program.
- Prefer declarative code that describes *what* to compute rather than *how* to compute it step by step.
- Use closures and partial application to create reusable, configurable function factories.