Skip to content

Commit c541176

Browse files
committed
Update README.md
1 parent b53856b commit c541176

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

execute-around/README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,28 @@ tags:
99
---
1010

1111
## Intent
12-
Execute Around idiom frees the user from certain actions that should always be executed before and after the business
13-
method. A good example of this is resource allocation and deallocation leaving the user to specify only what to do with
14-
the resource.
12+
13+
Execute Around idiom frees the user from certain actions that should always be executed before and
14+
after the business method. A good example of this is resource allocation and deallocation leaving
15+
the user to specify only what to do with the resource.
1516

1617
## Explanation
1718

1819
Real world example
1920

20-
> We need to provide a class that can be used to write text strings to files. To make it easy for the user we let our service class open and close the file automatically, the user only has to specify what is written into which file.
21+
> We need to provide a class that can be used to write text strings to files. To make it easy for
22+
> the user we let our service class open and close the file automatically, the user only has to
23+
> specify what is written into which file.
2124
2225
In plain words
2326

2427
> Execute Around idiom handles boilerplate code before and after business method.
2528
2629
[Stack Overflow](https://stackoverflow.com/questions/341971/what-is-the-execute-around-idiom) says
2730

28-
> Basically it's the pattern where you write a method to do things which are always required, e.g. resource allocation and clean-up, and make the caller pass in "what we want to do with the resource".
31+
> Basically it's the pattern where you write a method to do things which are always required, e.g.
32+
> resource allocation and clean-up, and make the caller pass in "what we want to do with the
33+
> resource".
2934
3035
**Programmatic Example**
3136

@@ -61,12 +66,15 @@ To utilize the file writer the following code is needed.
6166
```
6267

6368
## Class diagram
69+
6470
![alt text](./etc/execute-around.png "Execute Around")
6571

6672
## Applicability
73+
6774
Use the Execute Around idiom when
6875

69-
* you use an API that requires methods to be called in pairs such as open/close or allocate/deallocate.
76+
* You use an API that requires methods to be called in pairs such as open/close or
77+
allocate/deallocate.
7078

7179
## Credits
7280

0 commit comments

Comments
 (0)