Slide 1

Slide 1 text

The Combinator Pattern Elegant Composition for Modern Python Developers Haim Michael blog.lifemichael.com

Slide 2

Slide 2 text

Haim Michael

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

Economics Books in Hebrew Software Development Books in English blog.lifemichael.com My Books

Slide 5

Slide 5 text

Courses (in Hebrew) @ https://academy.lifemichael.com/he More Than 25 Online Courses on Udemy blog.lifemichael.com My Courses

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

First Class Objects

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

What is a Design Pattern

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

The Problem

Slide 13

Slide 13 text

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)

Slide 14

Slide 14 text

The Programming Problem @dataclass class User: username: str password: str ... def is_password_ valid(self) -> bool: ... return check_upper() and check_digit()

Slide 15

Slide 15 text

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.

Slide 16

Slide 16 text

The Real Problem We model logic as control flow, not as composable units. Violation of the Open-Closed Principle.

Slide 17

Slide 17 text

The Solution

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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“)

Slide 20

Slide 20 text

Conclusions © 2025 Haim Michael 20251118

Slide 21

Slide 21 text

The Single Responsibility Principle The SRP (Single Responsibility Principle) is achieved through the separation of concerns we get.

Slide 22

Slide 22 text

The Open-Closed Principle We can easily create new combinations of logic units without changing the logic units themselves.

Slide 23

Slide 23 text

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.

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

No content