TY - BOOK AU - Metsker,Steven John AU - Wake,William C. TI - Design patterns in Java / SN - 9788131713082 U1 - 005.13/3 22 PY - 2007/// CY - New Delhi PB - Pearson KW - Java (Computer program language) KW - Software patterns N1 - Includes bibliographical references (p. 447-448) and index; 1 Contents 2 Preface vii 3 Chapter 1: introduction 1 4 Why patterns? 1 5 Why design patterns? 2 6 Why java? 3 7 Uml 3 8 Challenges 4 9 The organization of this book 4 10 Welcome to oozinoz! 6 11 Summary 6 12 Part i: interface _patterns 13 Chapter 2: introducing interfaces 9 14 Interfaces and abstract classes 9 15 Interfaces and obligations 11 16 Summary 13 17 Beyond ordinary interfaces 13 18 Chapter 3: adapter 15 19 Adapting to an interface 15 20 Class and object adapters 21 21 Adapting data for a jtable 25 22 Identifying adapters 31 23 Summary 32 24 Chapter 4: facade 35 25 Facades, utilities, and demos 35 26 Refactoring to facade 37 27 Summary 49 28 Chapter 5: composite 51 29 An ordinary composite 52 30 Recursive behavior in composites 52 31 Composites, trees, and cycles 55 32 Composites with cycles 60 33 Consequences of cycles 65 34 Summary 65 35 Chapter 6: bridge 67 36 An ordinary abstraction-on the way to bridge 67 37 From abstraction to bridge 70 38 Drivers as bridges 72 39 Database drivers 73 40 Summary 75 41 Part ii: responsibility _patterns 42 Chapter 7: introducing responsibility 79 43 Ordinary responsibility 80 44 Controlling responsibility with visibility 82 45 Summary 83 46 Beyond ordinary responsibility 83 47 Chapter 8: singleton 85 48 Singleton mechanics 85 49 Singletons and threads 87 50 Recognizing singleton 88 51 summary 90 52 Chapter 9: observer 91 53 A classic example-observer in guis 91 54 Model/view/controller 96 55 Maintaining an observable object 102 56 Summary 105 57 Chapter 10: mediator 107 58 A classic example-gui mediators 107 59 Mediators of relational integrity 112 60 Summary 120 61 Chapter 11: proxy 123 62 A classic example-image proxies 123 63 Image proxies reconsidered 128 64 Remote proxies 131 65 Dynamic proxies 137 66 Summary 142 67 Chapter 12: chain of responsibility 143 68 An ordinary chain of responsibility 143 69 Refactoring to chain of responsibility 145 70 Anchoring a chain 148 71 Chain of responsibility without composite 150 72 Summary 150 73 Chapter 13: flyweight 151 74 Immutability 151 75 Extracting the immutable part of a flyweight 152 76 Sharing flyweights 154 77 Summary 158 78 Part iii: construction _patterns 79 Chapter 14: introducing construction 161 80 A few construction challenges 161 81 Summary 163 82 Beyond ordinary construction 163 83 Chapter 15: builder 165 84 An ordinary builder 165 85 Building under constraints 168 86 A forgiving builder 171 87 Summary 171 88 Chapter 16: factory method 173 89 A classic example-iterators 173 90 Recognizing factory method 174 91 Taking control of which class to instantiate 175 92 Factory method in parallel hierarchies 177 93 Summary 180 94 Chapter 17: abstract factory 181 95 A classic example-gui kits 181 96 Abstract factories and factory method 188 97 Packages and abstract factories 193 98 Summary 194 99 Chapter 18: prototype 195 100 Prototypes as factories 196 101 Prototyping with clones 197 102 Summary 200 103 Chapter 19: memento 201 104 A classic example-using memento for undo 201 105 Memento durability 209 106 Persisting mementos across sessions 209 107 Summary 213 108 Part iv: operation _patterns 109 Chapter 20: introducing operations 217 110 Operations and methods 217 111 Signatures 218 112 Exceptions 219 113 Algorithms and polymorphism 220 114 Summary 222 115 Beyond ordinary operations 223 116 Chapter 21: template method 225 117 A classic example-sorting 225 118 Completing an algorithm 229 119 Template method hooks 231 120 Refactoring to template method 233 121 Summary 235 122 Chapter 22 : state 237 123 Modeling states 237 124 Refactoring to state 241 125 Making states constant 246 126 Summary 248 127 Chapter 23: strategy 249 128 Modeling strategies 249 129 Refactoring to strategy 252 130 Comparing strategy and state 256 131 Comparing strategy and template method 257 132 Summary 257 133 Chapter 24: command 259 134 A classic example-menu commands 259 135 Using command to supply a service 262 136 Command hooks 264 137 Command in relation to other patterns 266 138 Summary 267 139 Chapter 25: interpreter 269 140 An interpreter example 269 141 Interpreters, languages, and parsers 283 142 Summary 283 143 Part v: extension patterns 144 Chapter 26: introducing extensions 287 145 Principles of object-oriented design 287 146 The liskov substitution principle 288 147 The law of demeter 289 148 Removing code smells 290 149 Beyond ordinary extensions 291 150 Summary 293 151 Chapter 27: decorator 295 152 A classic example-streams and writers 295 153 Function wrappers 305 154 Decorator in relation to other patterns 314 155 Summary 315 156 Chapter 28: iterator 317 157 Ordinary iteration 317 158 Thread-safe iteration 319 159 Iterating over a composite 326 160 Summary 336 161 Chapter 29: visitor 339 162 Visitor mechanics 339 163 An ordinary visitor 341 164 Visitor cycles 348 165 Visitor risks 353 166 Summary 354 167 Part vi: appendixes 168 Appendix a: directions 355 169 Get the most out of this book 355 170 Understand the classics 356 171 Weave patterns into your code 356 172 Keep learning 357 173 Appendix b: solutions 359 174 Appendix c: oozinoz source 439 175 Acquiring and using the source 439 176 Building the oozinoz code 439 177 Testing the code with junit 440 178 Finding files yourself 440 179 Summary 441 180 Appendix d: uml at a glance 443 181 Classes 444 182 Class relationships 446 183 Interfaces 447 184 Objects 448 185 States 449 186 Glossary 451 187 Bibliography 459 188 Index ER -