Bitter Java

Free Download

Authors:

ISBN: 193011043X

Size: 5 MB (5138294 bytes)

Pages: 373/373

File format:

Language:

Publishing Year:

Category: Tags: , ,

Bruce Tate193011043X

В русском переводе — “Горький вкус Java”. Книга о том, почему Java может “горчить” — о проектных ошибках, об антипаттернах проектирования серверных приложений Java (сервлеты, JSP, компоненты EJB). Для программистов Java среднего уровня, аналитиков или разработчиков архитектур, не желающих наступать на грабли.
Лично я жалею, что эта книга не попалась мне, когда я участвовала в своем первом проекте с использованием J2EE.

Table of contents :
Cover……Page 1
Title page……Page 6
Contents……Page 8
foreword……Page 18
preface……Page 20
acknowledgments……Page 24
about this book……Page 26
about the cover illustration……Page 30
The basics……Page 32
1. Bitter tales……Page 34
1.1 A Java development free fall……Page 35
1.1.1 Antipatterns in life……Page 37
1.2 Using design patterns accentuates the positive……Page 38
1.2.1 Design patterns online……Page 39
1.3 Antipatterns teach from the negative……Page 40
1.3.1 Some well-known antipatterns……Page 41
1.3.2 Antipatterns in practice……Page 42
1.3.3 Antipattern resources……Page 43
1.4 Antipattern ideas are not new……Page 44
1.4.1 Learning from the industry……Page 45
1.4.2 Detective work……Page 46
1.5 Why Bitter Java?……Page 48
1.5.2 Bitter Java tools……Page 49
1.5.3 The Bitter Java organization……Page 50
1.6 Looking ahead……Page 52
2. The bitter landscape……Page 54
2.1.1 The benefits of layering……Page 55
2.1.2 Layering can work against us……Page 57
2.2.1 Internet topologies affect our applications……Page 59
2.2.2 Enterprise layers add security and overhead……Page 60
2.2.3 Standards enable the Internet and add layers……Page 62
2.2.4 TCP and IP provide low-level communications……Page 63
2.2.5 HTTP provides application-level transport……Page 64
2.2.6 HTML and XML……Page 65
2.2.7 Mini-antipattern: Too Many Web Page Items……Page 66
2.3 Object technologies and antipatterns……Page 68
2.3.2 Inheritance enables packaging of common behavior……Page 69
2.3.4 Mini-antipatterns: Excessive Layering……Page 70
2.4 Java technologies solve antipatterns……Page 73
2.5 Major problems with the waterfall……Page 75
2.5.2 Mini-antipatterns: Incomplete Process Transitions……Page 76
2.5.3 Programming horizons: Extreme programming……Page 77
2.7 Antipatterns in this chapter……Page 79
Server-side Java antipatterns……Page 82
3. Bitter servlets……Page 84
3.1.1 An early antipattern: The Magic Pushbutton……Page 85
3.1.3 Failing to separate model and view……Page 87
3.1.4 Breaking out the model……Page 89
3.2 Antipattern: The Magic Servlet……Page 90
3.2.1 Can we use servlets as the model?……Page 91
3.2.2 Stumbling into the Magic Servlet trap……Page 93
3.2.3 Causes of the Magic Servlet……Page 97
3.3.1 Break out the model……Page 98
3.3.2 Wrapping the model with command objects……Page 99
3.3.3 Separating the model logic……Page 100
3.3.4 Separating the return trip……Page 105
3.3.5 Using a JSP for the return trip……Page 108
3.5 Antipattern in this chapter……Page 110
4. Bitter JSPs……Page 112
4.1.1 Recognizing the danger signs……Page 113
4.2.1 This program lacks model-view separation……Page 115
4.2.2 Solution: Refactor to Model-View-Controller……Page 117
4.3.1 Should we combine multiple JSPs?……Page 119
4.3.2 An example combining two interfaces……Page 120
4.3.4 Making decisions in the controller servlet……Page 125
4.4 Mini-antipatterns: Coarse and Fine Commands……Page 129
4.4.2 Solution: Refactor to appropriate granularity……Page 130
4.4.3 Tips for granularity……Page 132
4.6 Reviewing the JSP antipatterns……Page 133
4.7 Antipatterns in this chapter……Page 134
5. Bitter cache management……Page 138
5.1 We need caches!……Page 139
5.2 Antipattern: The Cacheless Cow……Page 140
5.2.1 Bitter BBS with no cache……Page 141
5.2.2 Building the model, view, and controller for ShowBoard……Page 143
5.2.3 Building the model, view, and controller for ShowThread……Page 146
5.2.4 Building the model, view and controller for AddPost……Page 150
5.3 Solution: Cache……Page 156
5.3.2 Solution 2: Cache commands……Page 157
5.3.3 Adding a cache to our BBS……Page 159
5.3.4 Possible enhancements to cached commands……Page 164
5.4.1 Concurrent access to static cache……Page 166
5.5 Antipattern: Synchronized Read/Write Bottlenecks……Page 167
5.5.1 Collisions between readers can hurt performance……Page 168
5.5.2 Read/write locks allow correct shared access……Page 169
5.7 Antipatterns in this chapter……Page 171
6. Bitter memories……Page 174
6.1 Understanding memory leaks and antipatterns……Page 175
6.1.1 Managing memory……Page 176
6.1.3 Reference counting……Page 177
6.1.4 Reachable objects……Page 179
6.2.1 Circumstances that cause Java memory leaks……Page 180
6.2.2 Finding Java leaks……Page 181
6.3 Antipattern: Lapsed Listeners Leak……Page 182
6.3.1 Examining some dangerous practices……Page 183
6.3.3 Solution 2: Shorten the life cycle of the anchor……Page 186
6.3.5 Reference objects simplify memory management……Page 187
6.4 Antipattern: The Leak Collection……Page 188
6.4.1 Causing trouble with caches and session state……Page 189
6.4.2 Solution 1: Search for common warning signs……Page 190
6.4.4 Solution 3: Use soft references for caches……Page 191
6.5.1 Make sure there is a leak……Page 192
6.5.2 Determine that the leak should be fixed……Page 193
6.5.3 Isolate the problem……Page 194
6.5.4 Determine the source and fix the problem……Page 195
6.5.5 Protect against the problem for the future……Page 196
6.6.1 String manipulation……Page 197
6.6.2 Collections……Page 198
6.7 Summary……Page 199
6.8 Antipatterns in this chapter……Page 200
7. Bitter connections and coupling……Page 202
7.2 Antipattern: Connection Thrashing……Page 203
7.2.2 Solution: Reuse connections with a pool……Page 205
7.2.3 Refactoring our BBS to add pooled connections……Page 208
7.2.4 Using getPooledConnection……Page 210
7.2.5 Using the J2EE connector architecture……Page 211
7.3 Antipattern: Split Cleaners……Page 212
7.3.1 Exceptions can lead to Split Cleaners……Page 214
7.3.2 Solution: Pair connection with cleanup, in finally……Page 215
7.4 Antipattern: Hardwired Connections……Page 216
7.4.1 The communications buffer……Page 217
7.4.3 Solution 1: Decouple with XML messages……Page 220
7.4.4 Solution 2: Delay binding with web services……Page 222
7.5 Mini-antipatterns for XML misuse……Page 223
7.5.2 XML’s bitter transitions……Page 224
7.6 Mini-antipatterns: Rigid XML……Page 225
7.6.1 Name collisions……Page 226
7.6.2 Rigid constructs……Page 228
7.6.3 Restrictive variable-content containers……Page 230
7.6.4 XML versioning……Page 232
7.7 Summary: Sweetening bitter connections……Page 233
7.8 Antipatterns in this chapter……Page 234
8. Bitter beans……Page 238
8.1.1 The component-based distributed architecture……Page 239
8.1.2 Types of EJBs……Page 240
8.2 Bitter BBS with EJBs……Page 241
8.2.1 Elements of an EJB application……Page 242
8.2.2 Building the remote interface……Page 244
8.2.3 Creating the home interface……Page 246
8.2.4 Implementing the bean class……Page 247
8.2.5 Defining the primary key……Page 252
8.2.6 Creating a deployment descriptor……Page 253
8.2.7 Using the model……Page 255
8.3 Antipattern: Round-tripping……Page 256
8.3.1 Computing the cost of a distributed deployment……Page 257
8.3.2 Chatty interfaces……Page 258
8.3.3 Solution: Group together round-trips with a facade……Page 259
8.3.4 Roots of round-tripping……Page 260
8.3.5 Refactoring the BBS with a facade……Page 261
8.4.1 Mini-antipattern: Bean-Managed Joins……Page 268
8.4.3 Mini-antipattern: Entity Beans for Lightweight Functions……Page 269
8.4.6 Troublesome scrollable lists……Page 271
8.4.7 Overall solution: Pick the right bean for the job……Page 272
8.5 Mini-antipattern: Everything Is an EJB……Page 273
8.6.1 Implementing a cache with a facade……Page 274
8.7 Smoothing out the bitter beans……Page 275
8.8 Antipatterns in this chapter……Page 276
The big picture……Page 280
9. Bitter hygiene……Page 282
9.1.1 Extreme programming requires good hygiene……Page 283
9.1.2 Coding standards protect against antipatterns……Page 284
9.2.1 Names matter……Page 286
9.2.2 Standards for names……Page 287
9.2.3 Braces and indentation……Page 291
9.2.4 Comments……Page 292
9.2.5 Tabs vs. spaces……Page 295
9.2.6 Editors……Page 296
9.3 Mini-antipatterns: Organization and visibility……Page 297
9.4 Mini-antipatterns: Structure……Page 300
9.4.2 Low-level design considerations……Page 301
9.4.3 Exceptions……Page 303
9.5 Mini-antipatterns: Leaks and performance……Page 304
9.6 Conventions for testing……Page 305
9.7.1 Buy, borrow, or steal?……Page 307
9.7.2 A sample style guide from Contextual, Inc…….Page 308
9.8 Summary of coding standards……Page 311
10.Bitter scalability……Page 314
10.1 Good topologies for performance……Page 315
10.1.1 Layering hardware in homogeneous groups……Page 317
10.2 Antipattern: Performance Afterthoughts……Page 320
10.2.1 Developing without performance planning……Page 321
10.2.2 Some real-world examples……Page 322
10.2.3 Solution: Plan for performance!……Page 323
10.3.1 Solution: Cache and Facade……Page 326
10.4 Antipattern: Bad Workload Management……Page 329
10.4.1 Solution: Workload Management……Page 330
10.4.2 True load balancing……Page 332
10.5.1 Solution 1: Dispatching with session affinity……Page 333
10.5.3 Using custom session bean solutions……Page 334
10.6 Antipattern: Thrash-tuning……Page 335
10.6.1 Solution: Use sound performance methodologies……Page 336
10.8 Antipatterns in this chapter……Page 338
11.Sweet parting thoughts……Page 342
11.1 Antipatterns help us on many levels……Page 343
11.1.2 Understanding antipatterns improves programs……Page 344
11.1.3 Understanding antipatterns makes you a better programmer……Page 345
11.2 Integrating antipatterns with process……Page 346
11.3 Next steps, last steps……Page 348
Cross-references of antipatterns……Page 350
bibliography……Page 360
A, B, C……Page 364
D, E……Page 365
J……Page 366
N, O, P……Page 367
R, S……Page 368
T, U, V, W……Page 369
X, Y, Z……Page 370

Reviews

There are no reviews yet.

Be the first to review “Bitter Java”
Shopping Cart
Scroll to Top