• Expedia Group Technology - Engineering Exploring the strategy pattern and functional programming alternatives in Kotlin Photo by Karsten Winegeart on Unsplash When designing software around business processes (e.g., orchestration services), one of the key challenges is organizing business logic in a way that is maintainable, scalable, and adaptable to change. • In this post, we’ll explore how to address such challenges with the Strategy Pattern (object-oriented, OO), and a Functional Programming (FP) alternative. • We’ll also discuss how to handle shared logic between strategies and compare the trade-offs of each approach. • Note: The examples and patterns in this post are for educational use and do not include any proprietary information. • We’ll base all the examples assuming the main logic is executed by invoking a “handler”. • The initial example: hardcoded logic in a handler Let’s start with a basic implementation where a Handler processes messages based on a lob (line of business) parameter.

Article Summaries:

  • Expedia Group Technology’s latest post examines how to structure business‑logic handling in Kotlin, comparing the classic Strategy Pattern with a functional‑programming (FP) approach. The author first shows a hard‑coded handler that routes messages by line of business (LOB) using a when block, then refactors it into separate MessageHandler implementations mapped by LOB. Next, the same separation is achieved with FP by storing lambda functions in a map and invoking the appropriate one at runtime. The article highlights maintainability, scalability, and adaptability trade‑offs between the object‑oriented and functional designs, offering practical code examples for each.

Sources: