Add README.md
This commit is contained in:
parent
b73ef6e6c5
commit
565f5a4e70
26
dirty-flag/README.md
Normal file
26
dirty-flag/README.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
layout: pattern
|
||||||
|
title: Dirty Flag
|
||||||
|
folder: dirty-flag
|
||||||
|
permalink: /patterns/dirty-flag/
|
||||||
|
categories: Other
|
||||||
|
tags:
|
||||||
|
- Java
|
||||||
|
- Difficulty-Easy
|
||||||
|
- Performance
|
||||||
|
---
|
||||||
|
|
||||||
|
## Intent
|
||||||
|
To avoid expensive re-acquisition of resources. The resources retain their identity, are kept in some
|
||||||
|
fast-access storage, and are re-used to avoid having to acquire them again.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Applicability
|
||||||
|
Use the Dirty Flag pattern when
|
||||||
|
|
||||||
|
* Repetitious acquisition, initialization, and release of the same resource causes unnecessary performance overhead.
|
||||||
|
|
||||||
|
## Credits
|
||||||
|
|
||||||
|
* [Design Patterns: Dirty Flag](https://www.takeupcode.com/podcast/89-design-patterns-dirty-flag/)
|
@ -16,10 +16,14 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
<version>3.8.1</version>
|
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -24,7 +24,7 @@ package org.dirty.flag;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import com.iluwatar.dirtyflag.App;
|
import com.iluwatar.dirtyflag.App;
|
||||||
|
|
||||||
|
@ -22,13 +22,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.dirty.flag;
|
package org.dirty.flag;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import com.iluwatar.dirtyflag.DataFetcher;
|
import com.iluwatar.dirtyflag.DataFetcher;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ import com.iluwatar.dirtyflag.DataFetcher;
|
|||||||
*/
|
*/
|
||||||
public class DirtyFlagTest {
|
public class DirtyFlagTest {
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void reset() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
|
public void reset() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
|
||||||
Field instance = DataFetcher.class.getDeclaredField("df");
|
Field instance = DataFetcher.class.getDeclaredField("df");
|
||||||
instance.setAccessible(true);
|
instance.setAccessible(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user