Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 1 observer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions 1 singleton/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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--)
Expand Down
10 changes: 9 additions & 1 deletion 10 singleton/src/main/java/com/iluwatar/singleton/IvoryTower.java
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -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;
}
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.