معرفی کتاب «Bitter Java» نوشتهٔ Bruce A. Tate، منتشرشده توسط نشر Manning Publications; Pearson Education در سال 2002. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است. «Bitter Java» در دستهٔ بدون دستهبندی قرار دارد.
Bruce Tate tried to make learning Java more fun. He failed miserable. What is this? A novel? A sports book? More than 50% of the contents talks about his kayaking and sporting experience. I was surprised that at the end of the book I did not find his list of dates. Luckily I bought it used. Stay away from this book.It is a well-known fact that most software projects fail. Drawing important lessons from common failures is the goal of Bitter Java.Reusing design patterns is not enough for success: patterns are like partial maps of dangerous terrain. They help, but don't prevent you from getting lost. Bitter Java teaches you how to recognize when you are lost, and how to get back on the right path. It illustrates common pitfalls of Java programming through code examples; it then refactors the code and explains why the new solutions are safe.about the bookThis book is a systematic account of common server-side Java programming mistakes, their causes and solutions. It covers antipatterns for base Java and J2EE concepts such as Servlets, JSPs, EJBs, enterprise connection models, and scalability.what's insideAfter studying antipatterns in this book such as:* Round-tripping* The magic servlet* The cacheless cow* Performance thrashingYou will be standing on the shoulders of those who failed before you.about the readerIf you are an intermediate Java programmer, analyst or architect eager to avoid the bitter experiences of others, this book is for you.about the authorBruce A. Tate is an Internet architect who developed the bitter Java concept after seeing a set of customer problems repeated and decided to collect these stories and publish their solutions. He is the coauthor of Objects for OS/2. He lives in Austin, Texas. contents......Page 6 foreword......Page 16 preface......Page 18 acknowledgments......Page 22 about this book......Page 24 about the cover illustration......Page 28 The basics......Page 30 Bitter tales......Page 32 1.1 A Java development free fall......Page 33 1.1.1 Antipatterns in life......Page 35 1.2 Using design patterns accentuates the positive......Page 36 1.2.1 Design patterns online......Page 37 1.3 Antipatterns teach from the negative......Page 38 1.3.1 Some well-known antipatterns......Page 39 1.3.2 Antipatterns in practice......Page 40 1.3.3 Antipattern resources......Page 41 1.4 Antipattern ideas are not new......Page 42 1.4.1 Learning from the industry......Page 43 1.4.2 Detective work......Page 44 1.5 Why Bitter Java?......Page 46 1.5.2 Bitter Java tools......Page 47 1.5.3 The Bitter Java organization......Page 48 1.6 Looking ahead......Page 50 The bitter landscape......Page 52 2.1.1 The benefits of layering......Page 53 2.1.2 Layering can work against us......Page 55 2.2.1 Internet topologies affect our applications......Page 57 2.2.2 Enterprise layers add security and overhead......Page 58 2.2.3 Standards enable the Internet and add layers......Page 60 2.2.4 TCP and IP provide low-level communications......Page 61 2.2.5 HTTP provides application-level transport......Page 62 2.2.6 HTML and XML......Page 63 2.2.7 Mini-antipattern: Too Many Web Page Items......Page 64 2.3 Object technologies and antipatterns......Page 66 2.3.2 Inheritance enables packaging of common behavior......Page 67 2.3.4 Mini-antipatterns: Excessive Layering......Page 68 2.4 Java technologies solve antipatterns......Page 71 2.5 Major problems with the waterfall......Page 73 2.5.2 Mini-antipatterns: Incomplete Process Transitions......Page 74 2.5.3 Programming horizons: Extreme programming......Page 75 2.7 Antipatterns in this chapter......Page 77 Server-side Java antipatterns......Page 80 Bitter servlets......Page 82 3.1.1 An early antipattern: The Magic Pushbutton......Page 83 3.1.3 Failing to separate model and view......Page 85 3.1.4 Breaking out the model......Page 87 3.2 Antipattern: The Magic Servlet......Page 88 3.2.1 Can we use servlets as the model?......Page 89 3.2.2 Stumbling into the Magic Servlet trap......Page 91 3.2.3 Causes of the Magic Servlet......Page 95 3.3.1 Break out the model......Page 96 3.3.2 Wrapping the model with command objects......Page 97 3.3.3 Separating the model logic......Page 98 3.3.4 Separating the return trip......Page 103 3.3.5 Using a JSP for the return trip......Page 106 3.5 Antipattern in this chapter......Page 108 Bitter JSPs......Page 110 4.1.1 Recognizing the danger signs......Page 111 4.2.1 This program lacks model-view separation......Page 113 4.2.2 Solution: Refactor to Model-View-Controller......Page 115 4.3.1 Should we combine multiple JSPs?......Page 117 4.3.2 An example combining two interfaces......Page 118 4.3.4 Making decisions in the controller servlet......Page 123 4.4 Mini-antipatterns: Coarse and Fine Commands......Page 127 4.4.2 Solution: Refactor to appropriate granularity......Page 128 4.4.3 Tips for granularity......Page 130 4.6 Reviewing the JSP antipatterns......Page 131 4.7 Antipatterns in this chapter......Page 132 Bitter cache management......Page 136 5.1 We need caches!......Page 137 5.2 Antipattern: The Cacheless Cow......Page 138 5.2.1 Bitter BBS with no cache......Page 139 5.2.2 Building the model, view, and controller for ShowBoard......Page 141 5.2.3 Building the model, view, and controller for ShowThread......Page 144 5.2.4 Building the model, view and controller for AddPost......Page 148 5.3 Solution: Cache......Page 154 5.3.2 Solution 2: Cache commands......Page 155 5.3.3 Adding a cache to our BBS......Page 157 5.3.4 Possible enhancements to cached commands......Page 162 5.4.1 Concurrent access to static cache......Page 164 5.5 Antipattern: Synchronized Read/Write Bottlenecks......Page 165 5.5.1 Collisions between readers can hurt performance......Page 166 5.5.2 Read/write locks allow correct shared access......Page 167 5.7 Antipatterns in this chapter......Page 169 Bitter memories......Page 172 6.1 Understanding memory leaks and antipatterns......Page 173 6.1.1 Managing memory......Page 174 6.1.3 Reference counting......Page 175 6.1.4 Reachable objects......Page 177 6.2.1 Circumstances that cause Java memory leaks......Page 178 6.2.2 Finding Java leaks......Page 179 6.3 Antipattern: Lapsed Listeners Leak......Page 180 6.3.1 Examining some dangerous practices......Page 181 6.3.3 Solution 2: Shorten the life cycle of the anchor......Page 184 6.3.5 Reference objects simplify memory management......Page 185 6.4 Antipattern: The Leak Collection......Page 186 6.4.1 Causing trouble with caches and session state......Page 187 6.4.2 Solution 1: Search for common warning signs......Page 188 6.4.4 Solution 3: Use soft references for caches......Page 189 6.5.1 Make sure there is a leak......Page 190 6.5.2 Determine that the leak should be fixed......Page 191 6.5.3 Isolate the problem......Page 192 6.5.4 Determine the source and fix the problem......Page 193 6.5.5 Protect against the problem for the future......Page 194 6.6.1 String manipulation......Page 195 6.6.2 Collections......Page 196 6.7 Summary......Page 197 6.8 Antipatterns in this chapter......Page 198 Bitter connections and coupling......Page 200 7.2 Antipattern: Connection Thrashing......Page 201 7.2.2 Solution: Reuse connections with a pool......Page 203 7.2.3 Refactoring our BBS to add pooled connections......Page 206 7.2.4 Using getPooledConnection......Page 208 7.2.5 Using the J2EE connector architecture......Page 209 7.3 Antipattern: Split Cleaners......Page 210 7.3.1 Exceptions can lead to Split Cleaners......Page 212 7.3.2 Solution: Pair connection with cleanup, in finally......Page 213 7.4 Antipattern: Hardwired Connections......Page 214 7.4.1 The communications buffer......Page 215 7.4.3 Solution 1: Decouple with XML messages......Page 218 7.4.4 Solution 2: Delay binding with web services......Page 220 7.5 Mini-antipatterns for XML misuse......Page 221 7.5.2 XML’s bitter transitions......Page 222 7.6 Mini-antipatterns: Rigid XML......Page 223 7.6.1 Name collisions......Page 224 7.6.2 Rigid constructs......Page 226 7.6.3 Restrictive variable-content containers......Page 228 7.6.4 XML versioning......Page 230 7.7 Summary: Sweetening bitter connections......Page 231 7.8 Antipatterns in this chapter......Page 232 Bitter beans......Page 236 8.1.1 The component-based distributed architecture......Page 237 8.1.2 Types of EJBs......Page 238 8.2 Bitter BBS with EJBs......Page 239 8.2.1 Elements of an EJB application......Page 240 8.2.2 Building the remote interface......Page 242 8.2.3 Creating the home interface......Page 244 8.2.4 Implementing the bean class......Page 245 8.2.5 Defining the primary key......Page 250 8.2.6 Creating a deployment descriptor......Page 251 8.2.7 Using the model......Page 253 8.3 Antipattern: Round-tripping......Page 254 8.3.1 Computing the cost of a distributed deployment......Page 255 8.3.2 Chatty interfaces......Page 256 8.3.3 Solution: Group together round-trips with a facade......Page 257 8.3.4 Roots of round-tripping......Page 258 8.3.5 Refactoring the BBS with a facade......Page 259 8.4.1 Mini-antipattern: Bean-Managed Joins......Page 266 8.4.3 Mini-antipattern: Entity Beans for Lightweight Functions......Page 267 8.4.6 Troublesome scrollable lists......Page 269 8.4.7 Overall solution: Pick the right bean for the job......Page 270 8.5 Mini-antipattern: Everything Is an EJB......Page 271 8.6.1 Implementing a cache with a facade......Page 272 8.7 Smoothing out the bitter beans......Page 273 8.8 Antipatterns in this chapter......Page 274 The big picture......Page 278 Bitter hygiene......Page 280 9.1.1 Extreme programming requires good hygiene......Page 281 9.1.2 Coding standards protect against antipatterns......Page 282 9.2.1 Names matter......Page 284 9.2.2 Standards for names......Page 285 9.2.3 Braces and indentation......Page 289 9.2.4 Comments......Page 290 9.2.5 Tabs vs. spaces......Page 293 9.2.6 Editors......Page 294 9.3 Mini-antipatterns: Organization and visibility......Page 295 9.4 Mini-antipatterns: Structure......Page 298 9.4.2 Low-level design considerations......Page 299 9.4.3 Exceptions......Page 301 9.5 Mini-antipatterns: Leaks and performance......Page 302 9.6 Conventions for testing......Page 303 9.7.1 Buy, borrow, or steal?......Page 305 9.7.2 A sample style guide from Contextual, Inc.......Page 306 9.8 Summary of coding standards......Page 309 Bitter scalability......Page 312 10.1 Good topologies for performance......Page 313 10.1.1 Layering hardware in homogeneous groups......Page 315 10.2 Antipattern: Performance Afterthoughts......Page 318 10.2.1 Developing without performance planning......Page 319 10.2.2 Some real-world examples......Page 320 10.2.3 Solution: Plan for performance!......Page 321 10.3.1 Solution: Cache and Facade......Page 324 10.4 Antipattern: Bad Workload Management......Page 327 10.4.1 Solution: Workload Management......Page 328 10.4.2 True load balancing......Page 330 10.5.1 Solution 1: Dispatching with session affinity......Page 331 10.5.3 Using custom session bean solutions......Page 332 10.6 Antipattern: Thrash-tuning......Page 333 10.6.1 Solution: Use sound performance methodologies......Page 334 10.8 Antipatterns in this chapter......Page 336 Sweet parting thoughts......Page 340 11.1 Antipatterns help us on many levels......Page 341 11.1.2 Understanding antipatterns improves programs......Page 342 11.1.3 Understanding antipatterns makes you a better programmer......Page 343 11.2 Integrating antipatterns with process......Page 344 11.3 Next steps, last steps......Page 346 Cross-references of antipatterns......Page 348 bibliography......Page 358 index......Page 362
Intended for intermediate Java programmers, analysts, and architects, this guide is a comprehensive analysis of common server-side Java programming traps (called anti-patterns) and their causes and resolutions. Based on a highly successful software conference presentation, this book is grounded on the premise that software programmers enjoy learning not from successful techniques and design patterns, but from bad programs, designs, and war stories - bitter examples. These educational techniques of graphically illustrating good programming practices through negative designs and anti-patterns also have one added benefit: they are fun.
A comprehensive analysis of common server-side Java programming traps, called anti-patterns, and their causes and resolutions, this book is based on the premise that software programmers enjoy learning not from successful techniques and design patterns, but from bad programs, design problems, and war stories: bitter examples