وبلاگ بلیان

Test-Driven Development: Extensive Tutorial

معرفی کتاب «Test-Driven Development: Extensive Tutorial» نوشتهٔ Grzegorz Gałezowski، منتشرشده توسط نشر Leanpub در سال 2023. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است. «Test-Driven Development: Extensive Tutorial» در دستهٔ بدون دسته‌بندی قرار دارد.

This ebook is an attempt to create open-source extensive tutorial on Test-Driven Development (TDD). Without going much into advanced aspects, such as applying TDD to object-oriented systems where multiple objects collaborate (which is a topic of part 2), I introduce the basic TDD philosophy and practices. In terms of design, most of the examples will be about methods of a single object being exercised. The goal is to focus on the core of TDD before going into its specific applications and to slowly introduce some concepts in an easy to grasp manner. After reading part 1, you will be able to effectively develop classes that have no dependencies on other classes (and on operating system resources) using TDD. I’m writing this book because I’m an enthusiast of Test-Driven Development (TDD). I believe that TDD is a major improvement over other software development methodologies that I have used to deliver quality software. I also believe that this is true not only for me, but for many other software developers. This raises the question: why don’t more people learn and use TDD as their software delivery method of choice? In my professional life, I haven’t seen the adoption rate to be high enough to justify the claim that TDD is now mainstream. The language of choice for code examples is C#, however, I made some exception from the typical C# code conventions. Table of Contents Front Matter Dedications Thanks! About code examples Notes for C# users Notes for Java users Part 1: Just the basics Motivation – the first step to learning TDD What TDD feels like Let's get it started! The essential tools Test framework Mocking framework Anonymous values generator Summary It's not (only) a test When a test becomes something more Taking it to the software development land A Specification rather than a test suite The differences between executable and ``traditional'' specifications Statement-first programming What's the point of writing a specification after the fact? ``Test-First'' means seeing a failure ``Test-After'' often ends up as ``Test-Never'' ``Test-After'' often leads to design rework Summary Practicing what we have already learned Let me tell you a story Act 1: The Car Act 2: The Customer's Site Act 3: Test-Driven Development Epilogue Sorting out the bits How to start? Start with a good name Start by filling the GIVEN-WHEN-THEN structure with the obvious Start from the end Start by invoking a method if you have one Summary How is TDD about analysis and what does ``GIVEN-WHEN-THEN'' mean? Is there a commonality between analysis and TDD? Gherkin TODO list... again! What is the scope of a unit-level Statement in TDD? Scope and level On what level do we specify our software? What should be the functional scope of a single Statement? Failing to adhere to the three rules How many assertions do I need? Summary Developing a TDD style and Constrained Non-Determinism A style? Principle: Tests As Specification First technique: Anonymous Input Second technique: Derived Values Third technique: Distinct Generated Values Fourth technique: Constant Specification Summary of the example Constrained non-determinism Summary Specifying functional boundaries and conditions Sometimes, an anonymous value is not enough Exceptions to the rule Rules valid within boundaries Combination of boundaries – ranges Summary Driving the implementation from Specification Type the obvious implementation Fake it (`til you make it) Triangulate Summary Part 2: Object-Oriented World On Object Composability Another task for Johnny and Benjamin A Quick Retrospective Telling, not asking Contractors A Quick Retrospective The need for mock objects Composability... again! Why do we need composability? Pre-object-oriented approaches Object-oriented programming to the rescue! The power of composition Summary – are you still with me? Web, messages and protocols So, again, what does it mean to compose objects? Alarms, again! Summary Composing a web of objects Three important questions A preview of all three answers When are objects composed? How does a sender obtain a reference to a recipient (i.e. how connections are made)? Receive as a constructor parameter Receive inside a message (i.e. as a method parameter) Receive in response to a message (i.e. as a method return value) Receive as a registered observer Where are objects composed? Composition Root Factories Summary Interfaces Classes vs interfaces Events/callbacks vs interfaces – few words on roles Small interfaces Protocols Protocols exist Protocol stability Craft messages to reflect the sender's intention Model interactions after the problem domain Message recipients should be told what to do, instead of being asked for information Most of the getters should be removed, return values should be avoided Protocols should be small and abstract Summary Classes Single Responsibility Principle Static recipients Summary Object Composition as a Language More readable composition root Refactoring for readability Composition as a language The significance of a higher-level language Some advice Summary Value Objects What is a value object? Example: money and names Value object anatomy Class signature Hidden data Hidden constructor String conversion methods Equality members The return of investment Summary Aspects of value objects design Immutability Handling of variability Special values Value types and Tell Don't Ask Summary Part 3: TDD in Object-Oriented World Mock Objects as a testing tool A backing example Interfaces Protocols Roles Behaviors Filling in the roles Using a mock channel Mocks as yet another context Summary Test-first using mock objects How to start? – with mock objects Responsibility and Responsibility Channel and DataDispatch one more time The first behavior Second behavior – specifying an error Summary Test-driving at the input boundary Fixing the ticket office Initial objects Bootstrap Writing the first Statement Summary Test-driving at the input boundary – a retrospective Outside-in development Workflow specification Data Transfer Objects and TDD Using a ReservationInProgress Interface discovery and the sources of abstractions Do I need all of this to do TDD? What's next? Test-driving object creation Test-driving object creation – a retrospective Limits of creation specification Why specify object creation? What do we specify in the creational Statements? Value object creation Summary Test-driving application logic Summary Test-driving value objects Initial value object Value semantics Case-insensitive comparison Input validation Summary Reaching the web of objects boundaries What time is it? Timers Threads Others What's inside the object? What are object's peers? What are object's internals? Examples of internals Summary THIS IS ALL I HAVE FOR NOW. WHAT FOLLOWS IS RAW, UNORDERED MATERIAL THAT'S NOT YET READY TO BE CONSUMED AS PART OF THIS TUTORIAL Mock objects as a design tool Responsibility-Driven Design Guidance of test smells Long Statements Lots of stubbing Specifying private members Revisiting topics from chapter 1 Constrained non-determinism in OO world Behavioral boundaries Triangulation Maintainable mock-based Statements Setup and teardown Refactoring mock code Part 4: Application architecture On stable/architectural boundaries Ports and adapters Physical separation of layers What goes into application? Application and other layers What goes into ports? Data transfer objects Ports are not a layer Part 5: TDD on application architecture level Designing automation layer Adapting screenplay pattern Driver Actors Data builders Further Reading Motivation – the first step to learning TDD The Essential Tools Value Objects Kent is a master at creating code that communicates well, is easy to understand, and is a pleasure to read. Every chapter of this book contains excellent explanations and insights into the smaller but important decisions we continuously have to make when creating quality code and classes. Erich Gamma, IBM Distinguished Engineer Many teams have a master developer who makes a rapid stream of good decisions all day long. Their code is easy to understand, quick to modify, and feels safe and comfortable to work with. If you ask how they thought to write something the way they did, they always have a good reason. This book will help you become the master developer on your team. The breadth and depth of topics will engage veteran programmers, who will pick up new tricks and improve on old habits, while the clarity makes it accessible to even novice developers. Russ Rufer, Silicon Valley Patterns Group Many people don t realize how readable code can be and how valuable that readability is. Kent has taught me so much, I m glad this book gives everyone the chance to learn from him. Martin Fowler, chief scientist, ThoughtWorks Code should be worth reading, not just by the compiler, but by humans. Kent Beck distilled his experience into a cohesive collection of implementation patterns. These nuggets of advice will make your code truly worth reading. Gregor Hohpe, author of Enterprise Integration Patterns In this book Kent Beck shows how writing clear and readable code follows from the application of simple principles. Implementation Patterns will help developers write intention revealing code that is both easy to understand and flexible towards future extensions. A must read for developers who are serious about their code. Sven Gorts Implementation Patterns bridges the gap between design and coding. Beck introduces a new way of thinking about programming by basing his discussion on values and principles. Diomidis Spinellis, author of Code Reading and Code Quality Software Expert Kent Beck Presents a Catalog of Patterns Infinitely Useful for Everyday Programming Great code doesn t just function: it clearly and consistently communicates your intentions, allowing other programmers to understand your code, rely on it, and modify it with confidence. But great code doesn t just happen. It is the outcome of hundreds of small but critical decisions programmers make every single day. Now, legendary software innovator Kent Beck known worldwide for creating Extreme Programming and pioneering software patterns and test-driven development focuses on these critical decisions, unearthing powerful implementation patterns for writing programs that are simpler, clearer, better organized, and more cost effective. Beck collects 77 patterns for handling everyday programming tasks and writing more readable code. This new collection of patterns addresses many aspects of development, including class, state, behavior, method, collections, frameworks, and more. He uses diagrams, stories, examples, and essays to engage the reader as he illuminates the patterns. You ll find proven solutions for handling everything from naming variables to checking exceptions. This book covers The value of communicating through code and the philosophy behind patterns How and when to create classes, and how classes encode logic Best practices for storing and retrieving state Behavior: patterns for representing logic, including alternative paths Writing, naming, and decomposing methods Choosing and using collections Implementation pattern variations for use in building frameworks Implementation Patterns will help programmers at all experience levels, especially those who have benefited from software patterns or agile methods. It will also be an indispensable resource for development teams seeking to work together more efficiently and build more maintainable software. No other programming book will touch your day-to-day work more often. " "Great code doesn t just happen. It is the outcome of hundreds of small but critical decisions programmers make every single day. Now, software innovator Kent Beck focuses on these critical decisions, unearthing "implementation patterns" for writing programs that are simpler, clearer, better organized, and more cost effective." "Beck collects 77 patterns for handling everyday programming tasks and writing more readable code. This new collection of patterns addresses many aspects of development, including class, state, behavior, method, collections, frameworks, and more. He uses diagrams, stories, examples, and essays to engage the reader as he illuminates the patterns. You'll find solutions for handling everything from naming variables to checking exceptions." "Implementation Patterns will help programmers at all experience levels, especially those who have benefited from software patterns or agile methods. It will also be a resource for development teams seeking to work together more efficiently and build more maintainable software."--Jacket Kent Beck. A Kent Beck Signature Book--cover. Includes Bibliographical References (p. 145-148) And Indexes.
دانلود کتاب Test-Driven Development: Extensive Tutorial