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>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -24,7 +24,7 @@ package org.dirty.flag;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.iluwatar.dirtyflag.App;
|
||||
|
||||
|
@ -22,13 +22,13 @@
|
||||
*/
|
||||
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.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.iluwatar.dirtyflag.DataFetcher;
|
||||
|
||||
@ -39,7 +39,7 @@ import com.iluwatar.dirtyflag.DataFetcher;
|
||||
*/
|
||||
public class DirtyFlagTest {
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void reset() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
|
||||
Field instance = DataFetcher.class.getDeclaredField("df");
|
||||
instance.setAccessible(true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user