Traps, Pitfalls, and Corner Cases
Joshua Bloch, Neal Gafter

#Java
#Puzzlers
#Pitfalls
💬 "هر زبان برنامهنویسی رفتارهای عجیب و غریب خودش رو داره. این کتاب جذاب، شگفتیهای زبان برنامهنویسی جاوا رو از طریق پازلهای سرگرمکننده و تفکربرانگیز به تصویر میکشه."
— گای استیل، همکار پژوهشی شرکت سان و یکی از نویسندگان کتاب داکیومنت رسمی زبان جاوا (The Java™ Language Specification)
💬 "خندیدم، گریه کردم و دستهام رو به نشانهی تحسین بالا بردم."
— تیم پیبرلز، مدیرعامل شرکت Prior Artisans LLC و عضو گروه تخصصی JSR 166
🔍 چقدر جاوا رو خوب میشناسید؟ آیا شم کارآگاهی در بررسی کدهای فنی دارید؟ تا حالا شده روزها وقتتون رو تلف پیدا کردن باگی کنید که دلیلش افتادن توی یکی از تلهها یا پیتفالهای (Pitfalls) پنهان خود جاوا یا کتابخانههای اون بوده باشه؟ به بازیهای فکری علاقه دارید؟ پس این کتاب دقیقاً برای شما نوشته شده!
💡 جاشوا بلاک و نیل گفتر، در ادامهی مسیر کتاب شاهکار Effective Java™، اینبار عمیقاً به بررسی ظرافتها و رفتارهای پیچیدهی زبان جاوا و کتابخانههای اصلی اون میپردازن. کتاب Java™ Puzzlers که با خطای دیدهای بصری و جذاب تصویرسازی شده، شامل ۹۵ پازل شیطانی و چالشبرانگیز هست که در کنار سرگرمکننده بودن، به شما آموزش میدن. هر کسی که یک آشنایی اولیه و کاربردی با جاوا داشته باشه متوجه این پازلها میشه، اما حتی برنامهنویسهای سینیور و باسابقه هم این پازلها رو چالشی خواهند یافت.
💻 بیشتر این پازلها در قالب قطعه کدهای کوتاهی ارائه میشن که رفتار و خروجی اونها اصلاً شبیه چیزی که به نظر میرسه نیست. آیا میتونید حدس بزنید کد چه کاری انجام میده؟ پازلها بر اساس قابلیتهایی که از زبان جاوا به کار میبرن دستهبندی شدن و پاسخهای کاملاً تشریحی و دقیق بلافاصله بعد از هر پازل قرار گرفته. این پاسخها خیلی فراتر از یک توضیح ساده برای رفتار برنامه میروند—اونها بهتون یاد میدن که چطور برای همیشه از این تلهها و چالشهای مخفی دوری کنید. در انتهای کتاب هم یک کاتالوگ کاربردی از تلهها و پیتفالها قرار داره که یک دستهبندی خلاصه و عالی رو برای مراجعات بعدی دم دستتون میگذاره.
🚀 با حل کردن این پازلها، دیگه هیچوقت دام رفتارهای غیرشهودی یا مبهمی که حتی با تجربهترین برنامهنویسها رو هم به اشتباه میاندازه، نخواهید افتاد.
۱. مقدمه
۲. پازلهای مربوط به عبارات و کدهای محاسباتی (Expressive Puzzlers)
۳. پازلهای کاراکتری (Puzzlers with Character)
۴. پازلهای مربوط به حلقهها (Loopy Puzzlers)
۵. پازلهای مربوط به اکسپشنها (Exceptional Puzzlers)
۶. پازلهای مربوط به کلاسها (Classy Puzzlers)
۷. پازلهای مربوط به کتابخانهها (Library Puzzlers)
۸. پازلهای پیشرفتهتر کلاسها (Classier Puzzlers)
۹. پازلهای بیشتر از کتابخانهها
۱۰. پازلهای پیشرفته (Advanced Puzzlers)
ضمیه آ: کاتالوگ تلهها و پیتفالها
ضمیمه ب: نکاتی درباره تصاویر خطای دید کتاب
👨💻 جاشوا بلاک، یکی از مهندسان ارشد سابق در گوگل و برنده جایزه معتبر جولت (Jolt Award) هست. اون پیش از این به عنوان مهندس برجسته در شرکت سان مایکروسیستمز و طراح ارشد سیستم در Transarc فعالیت میکرده. جاش رهبری دیزاین و پیادهسازی بسیاری از قابلیتهای اصلی پلتفرم جاوا رو بر عهده داشته که از جملهی اونها میتونیم به توسعههای زبانی در نسخه JDK 5.0 و فریمورک فوقالعاده و برنده جایزه Java Collections Framework اشاره کنیم. اون مدرک دکترای علوم کامپیوتر خودش رو از دانشگاه کارنگی ملون گرفته.
👨💻 نیل گفتر، مهندس نرمافزار و مبشر (Evangelist) باسابقه جاوا در گوگل هست. اون قبلاً مهندس ارشد در سان مایکروسیستمز بوده، جایی که رهبری توسعه کامپایلر جاوا (Java compiler) رو بر عهده داشته و ویژگیهای زبانی جاوا رو از نسخه ۱.۴ تا ۵.۰ پیادهسازی کرده. نیل همچنین از اعضای کمیته استانداردسازی C++ بوده و رهبری توسعه کامپایلرهای C و C++ رو در شرکتهای سان مایکروسیستمز، Microtec Research و تگزاس اینسترومنتس بر عهده داشته. اون مدرک دکترای علوم کامپیوتر خودش رو از دانشگاه روچستر دریافت کرده.
"Every programming language has its quirks. This lively book reveals oddities of the Java programming language through entertaining and thought-provoking programming puzzles."
—Guy Steele, Sun Fellow and coauthor of The Java™ Language Specification
"I laughed, I cried, I threw up (my hands in admiration)."
—Tim Peierls, president, Prior Artisans LLC, and member of the JSR 166 Expert Group
How well do you really know Java? Are you a code sleuth? Have you ever spent days chasing a bug caused by a trap or pitfall in Java or its libraries? Do you like brainteasers? Then this is the book for you!
In the tradition of Effective Java™, Bloch and Gafter dive deep into the subtleties of the Java programming language and its core libraries. Illustrated with visually stunning optical illusions, Java™ Puzzlers features 95 diabolical puzzles that educate and entertain. Anyone with a working knowledge of Java will understand the puzzles, but even the most seasoned veteran will find them challenging.
Most of the puzzles take the form of a short program whose behavior isn't what it seems. Can you figure out what it does? Puzzles are grouped loosely according to the features they use, and detailed solutions follow each puzzle. The solutions go well beyond a simple explanation of the program's behavior--they show you how to avoid the underlying traps and pitfalls for good. A handy catalog of traps and pitfalls at the back of the book provides a concise taxonomy for future reference.
Solve these puzzles and you'll never again fall prey to the counterintuitive or obscure behaviors that can fool even the most experienced programmers.
Table of Contents
1. Introduction
2. Expressive Puzzlers
3. Puzzlers with Character
4. loopy Puzzlers
5. Exceptional Puzzlers
6. Classy Puzzlers
7. Library Puzzlers
8. Classier Puzzlers
9. More Library Puzzlers
10. Advanced Puzzlers
A: Catalog of Traps and Pitfalls
B: Notes on the Illusions
Joshua Bloch is a principal engineer at Google and a Jolt Award-winner. He was previously a distinguished engineer at Sun Microsystems and a senior systems designer at Transarc. Josh led the design and implementation of numerous Java platform features, including JDK 5.0 language enhancements and the award-winning Java Collections Framework. He holds a Ph.D. in computer science from Carnegie Mellon University.
Neal Gafter is a software engineer and Java evangelist at Google. He was previously a senior staff engineer at Sun Microsystems, where he led the development of the Java compiler and implemented the Java language features in releases 1.4 through 5.0. Neal was a member of the C++ Standards Committee and led the development of C and C++ compilers at Sun Microsystems, Microtec Research, and Texas Instruments. He holds a Ph.D. in computer science from the University of Rochester.









