X Tutup
Skip to content

Commit 565f5a4

Browse files
Sia Wai SuanSia Wai Suan
authored andcommitted
Add README.md
1 parent b73ef6e commit 565f5a4

File tree

4 files changed

+38
-8
lines changed

4 files changed

+38
-8
lines changed

dirty-flag/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
layout: pattern
3+
title: Dirty Flag
4+
folder: dirty-flag
5+
permalink: /patterns/dirty-flag/
6+
categories: Other
7+
tags:
8+
- Java
9+
- Difficulty-Easy
10+
- Performance
11+
---
12+
13+
## Intent
14+
To avoid expensive re-acquisition of resources. The resources retain their identity, are kept in some
15+
fast-access storage, and are re-used to avoid having to acquire them again.
16+
17+
![alt text](./etc/dirty-flag.png "Dirty Flag")
18+
19+
## Applicability
20+
Use the Dirty Flag pattern when
21+
22+
* Repetitious acquisition, initialization, and release of the same resource causes unnecessary performance overhead.
23+
24+
## Credits
25+
26+
* [Design Patterns: Dirty Flag](https://www.takeupcode.com/podcast/89-design-patterns-dirty-flag/)

dirty-flag/pom.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@
1616
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1717
</properties>
1818
<dependencies>
19+
<dependency>
20+
<groupId>org.junit.jupiter</groupId>
21+
<artifactId>junit-jupiter-api</artifactId>
22+
<scope>test</scope>
23+
</dependency>
1924
<dependency>
20-
<groupId>junit</groupId>
21-
<artifactId>junit</artifactId>
22-
<version>3.8.1</version>
25+
<groupId>org.junit.jupiter</groupId>
26+
<artifactId>junit-jupiter-engine</artifactId>
2327
<scope>test</scope>
2428
</dependency>
2529
</dependencies>

dirty-flag/src/test/java/org/dirty/flag/AppTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
import java.io.IOException;
2626

27-
import org.junit.Test;
27+
import org.junit.jupiter.api.Test;
2828

2929
import com.iluwatar.dirtyflag.App;
3030

dirty-flag/src/test/java/org/dirty/flag/DirtyFlagTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
*/
2323
package org.dirty.flag;
2424

25-
import static org.junit.Assert.assertTrue;
25+
import static org.junit.jupiter.api.Assertions.assertTrue;
2626

2727
import java.lang.reflect.Field;
2828
import java.util.List;
2929

30-
import org.junit.Before;
31-
import org.junit.Test;
30+
import org.junit.jupiter.api.BeforeEach;
31+
import org.junit.jupiter.api.Test;
3232

3333
import com.iluwatar.dirtyflag.DataFetcher;
3434

@@ -39,7 +39,7 @@
3939
*/
4040
public class DirtyFlagTest {
4141

42-
@Before
42+
@BeforeEach
4343
public void reset() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
4444
Field instance = DataFetcher.class.getDeclaredField("df");
4545
instance.setAccessible(true);

0 commit comments

Comments
 (0)
X Tutup