intermediate
OOP versus functional style
Compare object behavior and mutable identity with functions, immutable data, composition pipelines, and explicit side-effect boundaries.
OOP bundles data and behavior on objects with mutable identity; functional style favors pure functions, immutable data, and explicit effect boundaries (IO at the edges). Many codebases blend both: immutable values inside entity methods, or Redux reducers (functional) driving React views (component objects).
Compare trade-offs on testability, concurrency, and where state lives—not ideology.
On interviews: discuss how you'd structure a pricing engine with discounts as pure functions versus polymorphic strategy objects.
Common pitfalls: claiming one paradigm always wins, hidden mutation in "functional" pipelines, and anemic services plus mutable globals.
The trade-off is localized mutation with clear objects versus reproducible transforms with immutable data.
Checklist:
- Place side effects at boundaries.
- Use pure functions for calculations.
- Choose style per subdomain, not globally.