Skip to content

Commit 21fed21

Browse files
committed
docs: raii diagram
1 parent 9e5d9e5 commit 21fed21

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

Diff for: resource-acquisition-is-initialization/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ Wikipedia says
3333

3434
> Resource acquisition is initialization (RAII) is a programming idiom used in several object-oriented, statically typed programming languages to describe a particular language behavior. Resource allocation (or acquisition) is done during object creation (specifically initialization), by the constructor, while resource deallocation (release) is done during object destruction (specifically finalization), by the destructor.
3535
36+
Sequence diagram
37+
38+
![Resource Acquisition Is Initialization sequence diagram](./etc/raii-sequence-diagram.png)
39+
3640
## Programmatic Example of RAII Pattern in Java
3741

3842
The RAII pattern is a common idiom used in software design where the acquisition of a resource is done during object creation (initialization), and the release of the resource is done during object destruction. This pattern is particularly useful in dealing with resource leaks and is critical in writing exception-safe code in C++. In Java, RAII is achieved with try-with-resources statement and interfaces `java.io.Closeable` and `AutoCloseable`.
Loading

0 commit comments

Comments
 (0)