From d2a85169043cd5e0ce0e549660ba305dc2b73a88 Mon Sep 17 00:00:00 2001 From: MADHURI-HS Date: Tue, 24 Mar 2026 11:24:40 +0530 Subject: [PATCH 1/3] Added database connection example to Singleton pattern --- singleton/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/singleton/README.md b/singleton/README.md index 92505061399e..484b8808b953 100644 --- a/singleton/README.md +++ b/singleton/README.md @@ -78,6 +78,7 @@ Use the Singleton pattern when * Configuration classes in many applications * Connection pools * File manager +* Database connection management systems to ensure a single shared instance across the application * [java.lang.Runtime#getRuntime()](http://docs.oracle.com/javase/8/docs/api/java/lang/Runtime.html#getRuntime%28%29) * [java.awt.Desktop#getDesktop()](http://docs.oracle.com/javase/8/docs/api/java/awt/Desktop.html#getDesktop--) * [java.lang.System#getSecurityManager()](http://docs.oracle.com/javase/8/docs/api/java/lang/System.html#getSecurityManager--) From f2d8546fd2ebd150b9ec45719e78605325829cac Mon Sep 17 00:00:00 2001 From: MADHURI-HS Date: Tue, 24 Mar 2026 12:22:21 +0530 Subject: [PATCH 2/3] Improved observer pattern documentation with use case explaination --- observer/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/observer/README.md b/observer/README.md index 6b8a700771f3..257e883e3040 100644 --- a/observer/README.md +++ b/observer/README.md @@ -174,6 +174,7 @@ Use the Observer pattern in any of the following situations: * When an abstraction has two aspects, one dependent on the other. Encapsulating these aspects in separate objects lets you vary and reuse them independently. * When a change to one object requires changing others, and you don't know how many objects need to be changed. * When an object should be able to notify other objects without making assumptions about who these objects are. In other words, you don't want these objects tightly coupled. +* This pattern is especially useful in event-driven systems where changes in one object need to be automatically reflected in multiple dependent objects. ## Real-World Applications of Observer Pattern in Java From dce1b3c81c0ceafcae2d2fdbe5d991d09015aa08 Mon Sep 17 00:00:00 2001 From: MADHURI-HS Date: Tue, 24 Mar 2026 12:38:52 +0530 Subject: [PATCH 3/3] Added JavaDoc for singleton instance method --- .../main/java/com/iluwatar/singleton/IvoryTower.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/singleton/src/main/java/com/iluwatar/singleton/IvoryTower.java b/singleton/src/main/java/com/iluwatar/singleton/IvoryTower.java index fc89ab312dd5..558a0610b2ce 100644 --- a/singleton/src/main/java/com/iluwatar/singleton/IvoryTower.java +++ b/singleton/src/main/java/com/iluwatar/singleton/IvoryTower.java @@ -24,7 +24,10 @@ */ package com.iluwatar.singleton; -/** Singleton class. Eagerly initialized static instance guarantees thread safety. */ +/** + * Singleton class. Eagerly initialized static instance guarantees thread + * safety. + */ public final class IvoryTower { /** Private constructor so nobody can instantiate the class. */ @@ -43,6 +46,11 @@ private IvoryTower() { * * @return instance of the singleton. */ + + /** + * Returns the single instance of IvoryTower. + * Ensures that only one instance exists throughout the application. + */ public static IvoryTower getInstance() { return INSTANCE; }