From 47a97fbf22b9776cd3fe1e5b542df910ca0db4d2 Mon Sep 17 00:00:00 2001 From: Shabin Francis Date: Mon, 8 Jun 2026 11:34:27 +0530 Subject: [PATCH 1/2] Add notification service example to Factory Method README --- factory-method/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/factory-method/README.md b/factory-method/README.md index 4334b052353d..d45a6aa0cac7 100644 --- a/factory-method/README.md +++ b/factory-method/README.md @@ -31,6 +31,9 @@ Real-world example In plain words > It provides a way to delegate the instantiation logic to child classes. +> +> Imagine a messaging app that can send notifications by Email, SMS, or Push Notifications. +> The user only asks to send a message. The Factory Method chooses and creates the correct notification service Wikipedia says From 690b4b889f490ec5cca842132d6510ced5b7ce00 Mon Sep 17 00:00:00 2001 From: Shabin Francis Date: Sat, 20 Jun 2026 18:04:51 +0530 Subject: [PATCH 2/2] docs: add comparison table for singleton implementations --- singleton/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/singleton/README.md b/singleton/README.md index 92505061399e..48cbc211aa24 100644 --- a/singleton/README.md +++ b/singleton/README.md @@ -37,6 +37,17 @@ Sequence diagram ![Singleton Pattern sequence diagram](./etc/singleton-sequence-diagram.png) +## Singleton Implementation Comparison (for eager and lazy initialization) + +| Feature | Eager Initialization | Thread-Safe Lazy Initialization | +|----------|----------|----------| +| Object Creation | During class loading | First call to `getInstance()` | +| Thread Safe | Yes | Yes | +| Synchronization Required | No | Yes | +| Memory Usage | Higher | Lower | +| Performance | Faster access | Slight synchronization overhead | +| Complexity | Simple | Moderate | + ## Programmatic Example of Singleton Pattern in Java Joshua Bloch, Effective Java 2nd Edition p.18