Академический Документы
Профессиональный Документы
Культура Документы
Les Design
Patterns en Java
Les 23 modles de conception fondamentaux
Steven John Metsker
et William C. Wake
2009 Pearson Education France Les design patterns en Java Steven John Metsker & William C. Wake
Pearson Education France a apport le plus grand soin la ralisation de ce livre afin de vous fournir une information complte et fiable. Cependant, Pearson Education France nassume de responsabilits, ni pour son utilisation, ni pour les contrefaons de brevets ou atteintes aux droits de tierces
personnes qui pourraient rsulter de cette utilisation.
Les exemples ou les programmes prsents dans cet ouvrage sont fournis pour illustrer les descriptions
thoriques. Ils ne sont en aucun cas destins une utilisation commerciale ou professionnelle.
Pearson Education France ne pourra en aucun cas tre tenu pour responsable des prjudices
ou dommages de quelque nature que ce soit pouvant rsulter de lutilisation de ces exemples ou
programmes.
Tous les noms de produits ou marques cits dans ce livre sont des marques dposes par leurs
propritaires respectifs.
Publi par Pearson Education France
47 bis, rue des Vinaigriers
75010 PARIS
Tl. : 01 72 74 90 00
www.pearson.fr
Aucune reprsentation ou reproduction, mme partielle, autre que celles prvues larticle L. 122-5 2 et 3 a) du code de la
proprit intellectuelle ne peut tre faite sans lautorisation expresse de Pearson Education France ou, le cas chant, sans
le respect des modalits prvues larticle L. 122-10 dudit code.
All rights reserved. No part of this book may be reproduced or transmitted in any form or by any means, electronic or
mechanical, including photocopying, recording or by any information storage retrieval system, without permission from
Pearson Education, Inc.
2009 Pearson Education France Les design patterns en Java Steven John Metsker & William C. Wake
1
2
3
4
5
7
7
8
9
10
11
Partie I
Patterns dinterface
Chapitre 2. Introduction aux interfaces ........................................................................
15
16
17
19
19
21
21
25
2009 Pearson Education France Les design patterns en Java Steven John Metsker & William C. Wake
IV
29
33
Rsum .........................................................................................................................
34
35
36
37
Rsum .........................................................................................................................
46
47
47
48
50
55
59
Rsum .........................................................................................................................
60
61
61
64
66
67
Rsum .........................................................................................................................
69
Partie II
Patterns de responsabilit
Chapitre 7. Introduction la responsabilit .................................................................
73
73
75
Rsum .........................................................................................................................
77
77
2009 Pearson Education France Les design patterns en Java Steven John Metsker & William C. Wake
79
79
81
82
84
85
85
90
96
99
101
101
106
112
115
115
120
122
128
133
135
135
137
140
142
142
143
Immuabilit ...................................................................................................................
Extraction de la partie immuable dun flyweight .........................................................
Partage des objets flyweight .........................................................................................
Rsum .........................................................................................................................
143
144
146
149
2009 Pearson Education France Les design patterns en Java Steven John Metsker & William C. Wake
VI
Partie III
Patterns de construction
Chapitre 14. Introduction la construction ..................................................................
153
153
155
155
157
157
160
163
164
165
165
166
167
169
171
173
173
178
182
182
183
183
185
187
189
189
196
2009 Pearson Education France Les design patterns en Java Steven John Metsker & William C. Wake
VII
197
200
Partie IV
Patterns dopration
Chapitre 20. Introduction aux oprations .....................................................................
203
203
205
205
206
208
209
211
211
215
218
219
221
223
223
227
231
233
235
236
238
242
243
243
2009 Pearson Education France Les design patterns en Java Steven John Metsker & William C. Wake
VIII
245
245
248
249
251
252
253
254
265
266
Partie V
Patterns dextension
Chapitre 26. Introduction aux extensions .....................................................................
Principes de la conception oriente objet .....................................................................
Le principe de substitution de Liskov ...........................................................................
La loi de Demeter .........................................................................................................
Elimination des erreurs potentielles ..............................................................................
Au-del des extensions ordinaires ................................................................................
Rsum .........................................................................................................................
269
269
270
271
273
273
274
277
277
285
292
293
295
295
297
303
310
311
313
2009 Pearson Education France Les design patterns en Java Steven John Metsker & William C. Wake
IX
315
315
318
323
328
330
Partie VI
Annexes
Annexe A. Recommandations ........................................................................................
333
333
334
334
336
337
337
337
338
338
338
338
339
340
341
341
342
342
342
343
343
344
2009 Pearson Education France Les design patterns en Java Steven John Metsker & William C. Wake
COMPOSITE ................................................................................................................
Solution 5.1 .............................................................................................................
Solution 5.2 .............................................................................................................
Solution 5.3 .............................................................................................................
Solution 5.4 .............................................................................................................
Solution 5.5 .............................................................................................................
Solution 5.6 .............................................................................................................
BRIDGE .......................................................................................................................
Solution 6.1 .............................................................................................................
Solution 6.2 .............................................................................................................
Solution 6.3 .............................................................................................................
Solution 6.4 .............................................................................................................
Solution 6.5 .............................................................................................................
Introduction la responsabilit .....................................................................................
Solution 7.1 .............................................................................................................
Solution 7.2 .............................................................................................................
Solution 7.3 .............................................................................................................
Solution 7.4 .............................................................................................................
SINGLETON ................................................................................................................
Solution 8.1 .............................................................................................................
Solution 8.2 .............................................................................................................
Solution 8.3 .............................................................................................................
Solution 8.4 ............................................................................................................
OBSERVER ..................................................................................................................
Solution 9.1 .............................................................................................................
Solution 9.2 .............................................................................................................
Solution 9.3 .............................................................................................................
Solution 9.4 .............................................................................................................
Solution 9.5 .............................................................................................................
Solution 9.6 .............................................................................................................
Solution 9.7 .............................................................................................................
MEDIATOR ..................................................................................................................
Solution 10.1 ...........................................................................................................
Solution 10.2 ...........................................................................................................
Solution 10.3 ...........................................................................................................
Solution 10.4 ...........................................................................................................
Solution 10.5 ...........................................................................................................
345
345
346
346
347
347
348
348
348
348
349
349
350
350
350
351
352
353
353
353
353
353
354
354
354
355
356
356
357
357
358
359
359
360
361
361
362
2009 Pearson Education France Les design patterns en Java Steven John Metsker & William C. Wake
XI
PROXY .........................................................................................................................
Solution 11.1 ...........................................................................................................
Solution 11.2 ...........................................................................................................
Solution 11.3 ...........................................................................................................
Solution 11.4 ...........................................................................................................
Solution 11.5 ...........................................................................................................
CHAIN OF RESPONSABILITY .................................................................................
Solution 12.1 ...........................................................................................................
Solution 12.2 ...........................................................................................................
Solution 12.3 ...........................................................................................................
Solution 12.4 ...........................................................................................................
Solution 12.5 ...........................................................................................................
FLYWEIGHT ...............................................................................................................
Solution 13.1 ...........................................................................................................
Solution 13.2 ...........................................................................................................
Solution 13.3 ...........................................................................................................
Solution 13.4 ...........................................................................................................
Introduction la construction .......................................................................................
Solution 14.1 ...........................................................................................................
Solution 14.2 ...........................................................................................................
Solution 14.3 ...........................................................................................................
BUILDER .....................................................................................................................
Solution 15.1 ...........................................................................................................
Solution 15.2 ...........................................................................................................
Solution 15.3 ...........................................................................................................
Solution 15.4 ...........................................................................................................
FACTORY METHOD ..................................................................................................
Solution 16.1 ...........................................................................................................
Solution 16.2 ...........................................................................................................
Solution 16.3 ...........................................................................................................
Solution 16.4 ...........................................................................................................
Solution 16.5 ...........................................................................................................
Solution 16.6 ...........................................................................................................
Solution 16.7 ...........................................................................................................
ABSTRACT FACTORY ...............................................................................................
Solution 17.1 ...........................................................................................................
Solution 17.2 ...........................................................................................................
362
362
363
363
363
364
364
364
365
366
366
367
368
368
369
370
370
371
371
372
372
373
373
373
374
374
375
375
376
376
376
377
378
378
379
379
380
2009 Pearson Education France Les design patterns en Java Steven John Metsker & William C. Wake
XII
380
381
381
382
382
383
383
384
384
384
385
385
386
386
387
387
387
388
388
388
389
389
389
390
390
390
390
390
391
391
392
392
392
392
393
2009 Pearson Education France Les design patterns en Java Steven John Metsker & William C. Wake
XIII
COMMAND .................................................................................................................
Solution 24.1 ...........................................................................................................
Solution 24.2 ...........................................................................................................
Solution 24.3 ...........................................................................................................
Solution 24.4 ...........................................................................................................
Solution 24.5 ...........................................................................................................
Solution 24.6 ...........................................................................................................
INTERPRETER ............................................................................................................
Solution 25.1 396
Solution 25.2 ...........................................................................................................
Solution 25.3 ...........................................................................................................
Solution 25.4 ...........................................................................................................
Introduction aux extensions ..........................................................................................
Solution 26.1 398
Solution 26.2 ...........................................................................................................
Solution 26.3 ...........................................................................................................
Solution 26.4 ...........................................................................................................
DECORATOR ..............................................................................................................
Solution 27.1 399
Solution 27.2 ...........................................................................................................
Solution 27.3 ...........................................................................................................
Solution 27.4 ...........................................................................................................
ITERATOR ...................................................................................................................
Solution 28.1 401
Solution 28.2 ...........................................................................................................
Solution 28.3 ...........................................................................................................
Solution 28.4 ...........................................................................................................
VISITOR .......................................................................................................................
Solution 29.1 403
Solution 29.2 ...........................................................................................................
Solution 29.3 ...........................................................................................................
Solution 29.4 ...........................................................................................................
Solution 29.5 ...........................................................................................................
393
393
393
395
395
396
396
396
405
405
406
397
397
397
398
398
398
399
399
400
401
401
401
402
402
402
403
403
403
404
404
2009 Pearson Education France Les design patterns en Java Steven John Metsker & William C. Wake
XIV
406
406
407
409
409
412
414
414
416
Glossaire ............................................................................................................................
417
Bibliographie .....................................................................................................................
425
Index ..................................................................................................................................
427
2009 Pearson Education France Les design patterns en Java Steven John Metsker & William C. Wake