A Personal Exercise in Empirical Software Design
Kent Beck

#Tidy_First
#Software_Design
🧩 «کدهای شلخته یک دردسر هستن. “مرتبسازی” کد برای خواناتر شدنش، یعنی باید اون رو به بخشهای قابل مدیریت تقسیم کنیم. در این راهنمای عملی، نویسنده Kent Beck (خالق Extreme Programming و از پیشگامان الگوهای نرمافزاری) توضیح میده کِی و کجا میتونی سراغ tidy کردن بری تا کیفیت کدت بهتر بشه، بدون اینکه ساختار کلی سیستم رو خراب کنی.»
🧠 به جای اینکه بخوای یکباره همه روشهای تمیزسازی رو یاد بگیری، این کتاب بهت اجازه میده با مثالهای کوچک شروع کنی که دقیقاً به درد همون مسئلهای میخورن که داری. مثلاً اگر یک تابع بزرگ و طولانی داری، یاد میگیری چطور اون رو منطقی به بخشهای کوچیکتر تقسیم کنی. در همین مسیر، با مفاهیم مهم طراحی نرمافزار هم آشنا میشی: Coupling، Cohesion، جریان نقدی تنزیلشده (Discounted Cash Flow) و Optionality.
🎯 این کتاب بهت کمک میکنه:
📌 درک کنی طراحی نرمافزار چطور کار میکنه و چه نیروهایی روی اون اثر میذارن
🔁 تفاوت بین تغییر رفتار سیستم و تغییر ساختار اون رو بفهمی
🧼 تجربه برنامهنویسی رو بهتر کنی؛ گاهی قبل از تغییر، کد رو تمیز کنی و گاهی بعدش
🧱 یاد بگیری تغییرات بزرگ رو در قدمهای کوچک و امن انجام بدی
🤝 طراحی نرمافزار رو به عنوان یک تمرین در روابط انسانی ببینی
📚 فهرست مطالب
بخش 1. Tidyings
فصل 1. گارد کلوز (Guard Clauses)
فصل 2. کد مرده (Dead Code)
فصل 3. نرمالسازی تقارنها (Normalize Symmetries)
فصل 4. رابط جدید، پیادهسازی قدیمی
فصل 5. ترتیب خواندن
فصل 6. ترتیب انسجام
فصل 7. نزدیک کردن اعلان و مقداردهی
فصل 8. متغیرهای توضیحی
فصل 9. ثابتهای توضیحی
فصل 10. پارامترهای صریح
فصل 11. خرد کردن دستورات
فصل 12. استخراج هِلپر
فصل 13. یککاسه کردن (One Pile)
فصل 14. توضیح با کامنت
فصل 15. حذف کامنتهای اضافی
بخش 2. مدیریت
فصل 16. تمیزسازی جداگانه
فصل 17. زنجیرهسازی
فصل 18. اندازه دستهها
فصل 19. ریتم
فصل 20. باز کردن گرهها
فصل 21. اول، بعد، بعدتر، هرگز
بخش 3. تئوری
فصل 22. ارتباط مفید بین عناصر
فصل 23. ساختار و رفتار
فصل 24. اقتصاد: ارزش زمانی و اختیار
فصل 25. یک دلار امروز > یک دلار فردا
فصل 26. آپشنها
فصل 27. آپشن در برابر جریان نقدی
فصل 28. تغییرات برگشتپذیر در ساختار
فصل 29. کوپلینگ
فصل 30. معادل بودن کانستنتین
فصل 31. کوپلینگ در برابر دکوپلینگ
فصل 32. انسجام
فصل 33. جمعبندی
🧠 Tidy First? یعنی چی؟
❓ «من باید این کد رو تغییر بدم ولی خیلی شلوغه… قدم بعدی چیه؟»
❓ «شاید اول باید تمیزش کنم… شاید هم نه.»
📌 این کتاب دقیقاً به همین سوالها جواب میده:
🧼 چه زمانی قبل از تغییر رفتار سیستم، کد رو تمیز کنیم
🛠️ چطور safe و مرحلهای tidy انجام بدیم
⛔ چطور بدون وسواس بیش از حد، تمیزسازی رو متوقف کنیم
💡 چرا اصلاً tidy کردن کار میکنه
🧠 نویسنده توضیح میده که طراحی نرمافزار در اصل یک مسئلهی روابط انسانی هست. اول از همه با خود برنامهنویس شروع میشه. چرا بعضی وقتها برای راحتتر شدن کارمون وقت نمیذاریم؟ چرا اونقدر درگیر تمیز کردن کد میشیم که فراموش میکنیم هدف اصلی کمک به کاربره؟
🚀 این کتاب بهت یاد میده:
🔁 تفاوت بین تغییر Behavior و تغییر Structure
⚖️ تعادل بین سرمایهگذاری روی ساختار و رفتار سیستم
🧠 اصول پایهی نیروهایی که روی طراحی نرمافزار اثر میذارن
🧩 چطور تغییرات بزرگ رو به قدمهای کوچک و امن بشکنی
🤝 نگاه انسانیتر به طراحی نرمافزار
👤 درباره نویسنده
🚀 Kent Beck برنامهنویس، خالق Extreme Programming، از پیشگامان Test-Driven Development و یکی از امضاکنندگان Agile Manifesto هست. او هماکنون به عنوان Chief Scientist در Mechanical Orchard فعالیت میکنه و روی بهتر کردن تجربه برنامهنویسی کار میکنه.
Messy code is a nuisance. "Tidying" code, to make it more readable, requires breaking it up into manageable sections. In this practical guide, author Kent Beck, creator of Extreme Programming and pioneer of software patterns, suggests when and where you might apply tidyings to improve your code while keeping the overall structure of the system in mind.
Instead of trying to master tidying all at once, this book lets you try out a few examples that make sense for your problem. If you have a big function containing many lines of code, you'll learn how to logically divide it into smaller chunks. Along the way, you'll learn the theory behind software design: coupling, cohesion, discounted cash flows, and optionality.
This book helps you:
Understand the basic theory of how software design works and the forces that act on it
Explore the difference between changes to a system's behavior and changes to its structure
Improve your programming experience by sometimes tidying first and sometimes tidying after
Learn how to make large changes in small, safe steps
Approach software design as an exercise in human relationships
Table of Contents
Part I. Tidyings
Chapter 1. Guard Clauses
Chapter 2. Dead Code
Chapter 3. Normalize Symmetries
Chapter 4. New Interface, Old Implementation
Chapter 5. Reading Order
Chapter 6. Cohesion Order
Chapter 7. Move Declaration and Initialization Together
Chapter 8. Explaining Variables
Chapter 9. Explaining Constants
Chapter 10. Explicit Parameters
Chapter 11 . Chunk Statements
Chapter 12. Extract Helper
Chapter 13. One Pile
Chapter 14. Explaining Comments
Chapter 15. Delete Redundant Comments
Part II. Managing
Chapter 16. Separate Tidying
Chapter 17. Chaining
Chapter 18. Batch Sizes
Chapter 19. Rhythm
Chapter 20. Getting Untangled
Chapter 21. First, After, Later, Never
Part Ill. Theory
Chapter 22. Beneficially Relating Elements
Chapter 23. Structure and Behavior
Chapter 24. Economics: Time Value and Optionality
Chapter 25. A Dollar Today> A Dollar Tomorrow
Chapter 26. Options
Chapter 27. Options Versus Cash Flows
Chapter 28. Reversible Structure Changes
Chapter 29. Coupling
Chapter 30. Constantine's Equivalence
Chapter 31 . Coupling Versus Decoupling
Chapter 32. Cohesion
Chapter 33. Conclusion
What is Tidy First?
“I have to change this code but it’s messy. What should I do next?”
“Maybe I should tidy the code before I make the change. Maybe. Some. Or maybe not.” These are questions you might ask yourself, and if there were an easy answer, I wouldn’t have to write a book to cover it.
Tidy First? describes:
When to tidy messy code before changing what it computes.
How to tidy messy code safely and efficiently.
How to stop tidying messy code.
Why tidying works.
Software design is an exercise in human relationships. In Tidy First? we start with the proverbial person in the mirror—with the programmer’s relationship with themself. Why don’t we take time to care for ourselves? Take time to make our work easier? Why do we go down the rabbithole of cleaning code to the exclusion of work that would help our users?
Tidy First? is the next step in my mission to help geeks feel safe in the world. It’s also the first step to take when addressing the common question posed above. Software design is a powerful tool to ease pain in the world—if it is used well. Used badly, it becomes just another instrument of oppression and becomes a drag on the effectiveness of software development.
By the end of this book, you will understand:
The fundamental difference between changes to the behavior of a system and changes to its structure.
The enabling magic of alternating investment in structure and investment in behavior, as a lone programmer changing code.
The basics of the theory of how software design works and the forces that act on it.
And you will be able to:
Improve your own experience of programming by sometimes tidying first (and sometimes tidy after).
Begin to make large changes in small, safe steps.
Approach software design as an exercise in human relationships
Audience
This book is meant for programmers, lead developers, hands-on software architects, and technical managers. It is not tied to any programming languages and all developers will also be able to read and apply the concepts in this book to their own projects. This book assumes that the reader is not new to programming in general.
About the Author
Kent Beck is a programmer, creator of Extreme Programming, pioneer of software patterns, coauthor of JUnit, rediscoverer of Test-Driven Development, and observer of 3X: Explore/Expand/Extract. Beck is also alphabetically the first signatory of the Agile Manifesto. He lives in San Francisco, California, and he is Chief Scientist at Mechanical Orchard, teaching skills to help geeks feel safe in the world.









