Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Combinator Pattern: Elegant Composition for...

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →

The Combinator Pattern: Elegant Composition for Modern Python Developers

As software systems evolve, their business logic often becomes increasingly complex. Logic that initially seems simple gradually gets embedded in classes and entities, making the code harder to maintain, extend, and reuse. Every new requirement may force developers to modify existing implementations, increasing complexity and the risk of introducing defects.

The Combinator Design Pattern offers an elegant way to address these challenges. Instead of implementing complex logic as tightly coupled control flow, we can represent individual rules as independent, first-class functions and compose them to construct more sophisticated behavior.

This presentation explores the Combinator Pattern from both theoretical and practical perspectives, showing how Python's support for first-class functions enables flexible, reusable software components.

We begin by reviewing first-class objects in Python and the role of design patterns in solving recurring software development problems. We then examine common design challenges, including business logic accumulating within entities and the difficulties that arise when requirements change.

Using password validation as a practical example, we show how you can define individual validation rules independently and combine them into more complex validation policies. Rather than hardcoding validation logic inside a class, we can assemble the required behavior from reusable building blocks.

The presentation also examines how the Combinator Pattern supports fundamental object-oriented design principles:

- Single Responsibility Principle (SRP): Separating individual logic units from the entities that use them, improving separation of concerns.
- Open-Closed Principle (OCP): Allowing developers to introduce new combinations of behavior without modifying existing logic units.
- Code Maintainability: Making implementations easier to understand, extend, and maintain by organizing logic into small, reusable components.

One of the central messages of this presentation is that complex software behavior does not necessarily require complex implementations. By modeling logic as composable units, developers can create flexible solutions that adapt more easily to changing requirements.

The Combinator Pattern demonstrates how thoughtful software design can simplify development while improving code quality and maintainability.

These slides are intended for Python developers, software architects, and anyone interested in design patterns, functional composition, and building cleaner, more maintainable software.

More information about this talk and the code samples it uses can be found at https://lifemichael.com/en/exploring-the-combinator-pattern-at-python-summit-2026/

Avatar for life michael

life michael

October 19, 2026

More Decks by life michael

Other Decks in Technology

Transcript

  1. My name is Haim Michael. I live in Tel Aviv,

    and I am the CEO & founder of Zindell Technologies, Ltd. My passion lies in teaching and lifelong learning. I have been into programming since my childhood. I have extensive experience with Java (30+ yrs), JavaScript (30+ yrs), C++ (30+ yrs), C# (20+ yrs), TypeScript (12+ yrs), Python (15+ yrs), PHP (20+ yrs), Scala (16+ yrs), and Kotlin (12+ yrs). Teaching advanced computer science topics at the university. blog.lifemichael.com Tel-Aviv, Israel
  2. XtremeJ XtremePython XtremeAI xtremej.dev xtremepython.dev meetup.com/lifemichael xtremeai.dev More Than 18000

    Followers https://linkedin.com/in/lifemichael Kiro Ambassador XtremeJS xtremejs.dev More Than 2800 Video Clips youtube.com/lifemichael blog.lifemichael.com Communities Builder
  3. Jacado - More Than 200 Games for Mobile Telephones –

    Years 2001- 2008 Zindell - Building AI Aligned Companies – Years 2026 - … nana.events prompo.ai zindrex.com ngager.pro jacado.games blog.lifemichael.com Passion to Build
  4. Functions is an Object def total(a:int, b:int) -> int: return

    a + b f = total print(f(1,2)) total 12FC f 12FC 12FC
  5. Design Patterns A design pattern is a solution for a

    recurring problem. Design patterns exist in many domains. Software development is one of them. The Once Upon a Time Animation Series https://www.youtube.com/watch?v=5RJ9YH_BhrQ
  6. The Programming Problem The logic in our software grows, and

    instead of being separated from the entities, it becomes part of them. Violation of the Single Responsibility Principle “A class should have one, and only one, reason to change.” (Robert C.Martin)
  7. The Programming Problem @dataclass class User: username: str password: str

    ... def is_password_ valid(self) -> bool: ... return check_upper() and check_digit()
  8. The Programming Problem When the logic is hardcoded rather than

    assembled, every new requirement forces us to modify the existing code. Violation of the Open-Closed Principle Modules should be open to extending their software entities but closed to their modification.
  9. The Real Problem We model logic as control flow, not

    as composable units. Violation of the Open-Closed Principle.
  10. What the Combinator Pattern Fixes Treat each rule (logic unit)

    as a first-class function (object). We can then combine them using composition. [Rule A] + [Rule B] + [Rule C] → [Combined Validator] The Lego Composition Model
  11. What the Combinator Pattern Fixes password_policy = ( min_length(8) .and_(has_uppercase())

    .and_(has_lowercase()) .and_(has_digit()) .and_(has_special_char()) .and_(no_whitespace()) ) password_policy.validate(“password123“)
  12. The Single Responsibility Principle The SRP (Single Responsibility Principle) is

    achieved through the separation of concerns we get.
  13. The Open-Closed Principle We can easily create new combinations of

    logic units without changing the logic units themselves.
  14. The Maintainability of Our Code The maintainability of our code

    has significantly improved. We can easily create new combinations of the logic units and we can easily create new logic units.
  15. Q&A Thanks for attending my talk :) WhatsApp +972.54.6655837 nana.events

    [email protected] https://linkedin.com/in/lifemichael nana.events prompo.ai https://blog.lifemichael.com Jacado jacado.games jacado.games prompo.ai ngager.pro life michael zindrex.com XtremeJ xtremej.dev XtremeJS xtremejs.dev XtremePython xtremepython.dev XtremeAI xtremeai.dev lifemichael.com meetup.com/lifemichael