Skip to content

Article about functional programming in kotlin#133

Open
patrickwilmes wants to merge 1 commit intoZuehlke:mainfrom
patrickwilmes:kotlin-functional-programming
Open

Article about functional programming in kotlin#133
patrickwilmes wants to merge 1 commit intoZuehlke:mainfrom
patrickwilmes:kotlin-functional-programming

Conversation

@patrickwilmes
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Contributor

@abishekanthony07 abishekanthony07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All in all the Blog is really expressive and on point!
I have mostly added suggestions to Kotlin code. Feel free to challenge them!
Thank you Patrick!

Comment thread src/articles/kotlin-functional-programming/index.md Outdated
Comment thread src/articles/kotlin-functional-programming/index.md Outdated
Comment thread src/articles/kotlin-functional-programming/index.md Outdated
Comment thread src/articles/kotlin-functional-programming/index.md Outdated
Comment thread src/articles/kotlin-functional-programming/index.md Outdated
Comment thread src/articles/kotlin-functional-programming/index.md Outdated
Comment thread src/articles/kotlin-functional-programming/index.md Outdated
Comment thread src/articles/kotlin-functional-programming/index.md Outdated
Comment thread src/articles/kotlin-functional-programming/index.md Outdated
Comment thread src/articles/kotlin-functional-programming/index.md Outdated
Co-authored-by: Abishek Anthony <Abishek.Anthony@zuehlke.com>
@patrickwilmes patrickwilmes force-pushed the kotlin-functional-programming branch from 051c867 to 3b05305 Compare April 30, 2026 09:27

## Functional and Object-Oriented: Not Opposites, but Complements

There’s no single “superior” paradigm. Paradigms are tools, each emphasizing a different aspect of design.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
There’s no single “superior” paradigm. Paradigms are tools, each emphasizing a different aspect of design.
There’s no single “superior” paradigm. Paradigms are tools, each emphasizing a different aspect of design.

- **OOP** models the world with _entities_ and _behavior_. It gives structure and relationships.
- **FP** models _data transformations_. It focuses on purity, predictability, and composition.

Viewed together:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Viewed together:
Viewed together:

- **FP** models _data transformations_. It focuses on purity, predictability, and composition.

Viewed together:
> **Use OOP to give your project structure, and FP to express logic clearly.**
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> **Use OOP to give your project structure, and FP to express logic clearly.**
> **Use OOP to give your project structure, and FP to express logic clearly.**


### What Makes a Function Pure?

A pure function must satisfy two requirements:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A pure function must satisfy two requirements:
A pure function must satisfy two requirements:

}
```

This is pure because:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This is pure because:
This is pure because:

You can think of a **monad** as a _computation context_ — a box that carries both a value and its meaning
(was it successful, optional, deferred?).

A monad provides three operations:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A monad provides three operations:
A monad provides three operations:

}
```

**Monads let you:**
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**Monads let you:**
**Monads let you:**

- Keep business logic clean
- Maintain purity—no hidden effects

Common monads you’ll encounter:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Common monads you’ll encounter:
Common monads you’ll encounter:


## When to Use Which Paradigm

### Functional Programming Shines When
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Functional Programming Shines When
### Functional Programming Shines When

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using titles, I would have used a different format:

Functional programming shines when ...

- ... you're tranforming data.
- ... logic is complex but composable
- ...

- You need thread safety
- You want testability and predictability

### OOP Shines When
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### OOP Shines When
### OOP Shines When

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants