| 
									
										
										
										
											2018-02-20 09:48:44 +00:00
										 |  |  | --- | 
					
						
							|  |  |  | layout: pattern | 
					
						
							|  |  |  | title: Dirty Flag | 
					
						
							|  |  |  | folder: dirty-flag | 
					
						
							|  |  |  | permalink: /patterns/dirty-flag/ | 
					
						
							| 
									
										
										
										
											2019-12-13 21:09:28 +02:00
										 |  |  | categories: Behavioral | 
					
						
							| 
									
										
										
										
											2018-02-20 09:48:44 +00:00
										 |  |  | tags: | 
					
						
							| 
									
										
										
										
											2019-12-13 21:09:28 +02:00
										 |  |  |  - Game programming | 
					
						
							| 
									
										
										
										
											2018-02-20 09:48:44 +00:00
										 |  |  |  - Performance | 
					
						
							|  |  |  | --- | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-07 20:05:35 +03:00
										 |  |  | ## Also known as
 | 
					
						
							|  |  |  | * IsDirty pattern | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-20 09:48:44 +00:00
										 |  |  | ## 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. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-07 20:01:13 +02:00
										 |  |  | ## Class diagram
 | 
					
						
							| 
									
										
										
										
											2018-02-20 09:48:44 +00:00
										 |  |  |  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## 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/) | 
					
						
							| 
									
										
										
										
											2020-07-07 20:05:35 +03:00
										 |  |  | * [J2EE Design Patterns](https://www.amazon.com/gp/product/0596004273/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0596004273&linkCode=as2&tag=javadesignpat-20&linkId=48d37c67fb3d845b802fa9b619ad8f31) |