Skip to content
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
3 changes: 3 additions & 0 deletions factory-method/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions singleton/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading