top of page

〈メンバー専用〉日本酒女子会

公開·18名のメンバー
Rustam Panov
Rustam Panov

How to Write Clean, Expressive, and Sustainable Code with TDD and OOD: A Review of Growing Object-Oriented Software, Guided by Tests


Growing Object-Oriented Software, Guided by Tests: A Book Review




If you are a software developer who wants to learn how to write high-quality code that is easy to maintain, test, and evolve, then you might be interested in reading Growing Object-Oriented Software, Guided by Tests by Steve Freeman and Nat Pryce. This book is a comprehensive guide to applying test-driven development (TDD) and object-oriented design (OOD) principles and practices in real-world projects. In this article, I will give you an overview of what the book is about, why you should read it, and how you can get it.




growing object-oriented software guided by tests mobi download



What is the book about?




The book is based on the authors' extensive experience in developing software using TDD and OOD techniques. They share their insights and wisdom on how to grow software incrementally and iteratively, driven by tests that specify the desired behavior and quality of the system. They also show how to design software that is modular, cohesive, decoupled, and expressive, using well-known patterns and principles such as dependency injection, mock objects, encapsulation, polymorphism, and more.


The main idea of the book




The main idea of the book is that software development is not a linear process of analysis, design, implementation, and testing, but rather a feedback loop of learning, experimenting, refining, and delivering. The authors argue that tests are not only a way to verify that the code works as expected, but also a way to communicate the intent and structure of the code, as well as a way to drive the design and evolution of the code. By writing tests first, before writing any production code, developers can focus on what they want to achieve rather than how they want to achieve it. They can also get immediate feedback on whether their code meets the requirements and whether it is easy to change and extend.


The structure of the book




The book is divided into five parts:



  • Part I introduces the concept and benefits of TDD with objects, as well as the tools and frameworks that support it.



  • Part II describes the process and practices of TDD with objects, such as how to start a project with a walking skeleton, how to maintain a test-driven cycle, how to achieve object-oriented style and design, and how to build on third-party code.



  • Part III presents a worked example of applying TDD with objects in a realistic project. The authors develop an auction sniper application from scratch using Java and JUnit. They demonstrate how to implement features incrementally using tests as specifications, how to refactor code using tests as safety nets, and how to handle failures using tests as diagnostics.



  • Part IV discusses some advanced topics and challenges in TDD with objects, such as how to listen to the tests for design feedback, how to improve test readability and maintainability, how to construct complex test data and matchers, and how to test persistence, threads, and asynchronous code.



  • Part V concludes with a brief history of mock objects and an appendix with a cheat sheet for jMock2 (a mocking framework) and a guide for writing custom Hamcrest matchers (a library for expressive assertions).



Why should you read the book?




The book is not only a technical manual, but also a philosophical manifesto. The authors advocate for a different way of thinking about and doing software development, one that is more agile, collaborative, and creative. They explain the rationale and benefits of TDD with objects, as well as the pitfalls and anti-patterns to avoid. They also provide practical advice and tips on how to apply TDD with objects in various contexts and scenarios. Here are some of the reasons why you should read the book:


The benefits of test-driven development (TDD)




TDD is a technique that involves writing tests before writing production code, and then writing just enough code to make the tests pass. The tests act as specifications, feedback, and documentation for the code. Some of the benefits of TDD are:



  • It helps you clarify your requirements and expectations before writing any code.



  • It helps you design your code in small, testable, and reusable units.



  • It helps you verify that your code works as intended and meets the quality standards.



  • It helps you refactor your code with confidence and without breaking existing functionality.



  • It helps you prevent bugs and regressions by catching them early and often.



  • It helps you document your code by showing how it should be used and what it should do.



The best practices of object-oriented design (OOD)




OOD is a paradigm that involves modeling software as a collection of objects that interact with each other through messages. Objects have state (attributes) and behavior (methods), and they encapsulate data and logic. Some of the best practices of OOD are:



  • It helps you organize your code in a modular and hierarchical way, using classes, interfaces, packages, and components.



  • It helps you achieve high cohesion and low coupling among your classes, by following the single responsibility principle, the open-closed principle, the Liskov substitution principle, the interface segregation principle, and the dependency inversion principle.



  • It helps you express your domain concepts and logic in a clear and natural way, using abstraction, inheritance, polymorphism, composition, delegation, and patterns.



  • It helps you isolate your dependencies and make your code more flexible and testable, by using dependency injection, mock objects, stubs, fakes, spies, and wrappers.



The practical examples and tools of the book




The book is full of concrete examples and illustrations that show how to apply TDD with objects in real-world projects. The authors use Java as the main programming language, but they also explain how to use other languages such as Ruby, Python, C#, or JavaScript. They also introduce and demonstrate how to use various tools and frameworks that support TDD with objects, such as:



  • JUnit: a unit testing framework for Java that allows you to write tests using annotations, assertions, runners, rules, categories, suites, etc.



  • jMock: a mocking framework for Java that allows you to create mock objects that simulate the behavior of real objects using expectations, actions, matchers, states, sequences, etc.



  • Hamcrest: a library for Java that allows you to write expressive assertions using matchers that describe the expected properties of objects.



  • Selenium: a tool for automating web browsers that allows you to write end-to-end tests for web applications using drivers, locators, commands, etc.



  • Window Licker: a library for Java that allows you to write end-to-end tests for Swing applications using drivers, components, gestures, etc.



How can you get the book?




The book is available in various formats and editions. You can also find different sources and prices for the book online. Here are some of the options:


The formats and editions of the book




The book was first published in 2009 by Addison-Wesley Professional as part of the Addison-Wesley Signature Series (Fowler). It has 384 pages and ISBN-13: 978-0321503626. The book is available in hardcover format as well as in digital formats such as PDF (Portable Document Format), EPUB (Electronic Publication), MOBI (Mobipocket), or Kindle. The digital formats can be read on various devices such as computers, tablets, smartphones, or e-readers.


The sources and prices of the book




The book can be purchased from various online retailers such as Amazon.com or Barnes & Noble.com. The prices may vary depending on the format, edition, condition, availability, shipping costs, etc. As of June 2023, from $29.99 for a hardcover copy to $19.79 for a Kindle edition on Amazon.com . You can also find some free or discounted copies of the book on other websites such as GitHub or O'Reilly Media. However, you should be careful about the quality and legality of these sources.


The bonus materials and resources of the book




The book also comes with some bonus materials and resources that can help you learn more about TDD with objects and OOD. Some of these are:







  • The online forums and communities where you can discuss and ask questions about TDD with objects and OOD, such as Stack Overflow, Reddit, Quora, etc.



Conclusion




In conclusion, Growing Object-Oriented Software, Guided by Tests is a book that I highly recommend to anyone who wants to improve their software development skills and practices. The book teaches you how to write clean, expressive, and sustainable code using TDD with objects and OOD techniques. The book also provides you with practical examples and tools that you can use in your own projects. The book is not only informative, but also engaging and entertaining. The authors write in a conversational style that makes you feel like they are talking to you directly. They also use humor, anecdotes, and metaphors to make their points more memorable and relatable. The book is not only a book, but also a journey that will change the way you think about and do software development.


FAQs




Here are some frequently asked questions about the book:



  • What are the prerequisites for reading the book?



You don't need any prior knowledge or experience in TDD with objects or OOD to read the book. However, you should have some basic familiarity with Java or another object-oriented programming language, as well as some general understanding of software development concepts and processes.


  • How long does it take to read the book?



The book has 384 pages, which means it can take anywhere from a few hours to a few days to read it depending on your reading speed and comprehension level. However, reading the book is not enough to master TDD with objects or OOD. You also need to practice what you learn by applying it to your own projects and experiments.


  • Is the book still relevant in 2023?



Yes, the book is still relevant in 2023. Although the book was published in 2009, the principles and practices of TDD with objects and OOD are timeless and universal. They can be applied to any programming language, framework, platform, or domain. The tools and frameworks that the authors use in the book may have changed or evolved over time, but they are not essential to understand or follow the book. You can easily find updated versions or alternatives of these tools and frameworks online.


  • What are some other books that are similar or complementary to this book?



Some other books that are similar or complementary to this book are:



  • Test Driven Development: By Example by Kent Beck: This is another classic book on TDD that shows how to write simple and elegant code using examples in Java and Python.



  • Clean Code: A Handbook of Agile Software Craftsmanship by Robert C. Martin: This is a book that teaches you how to write code that is readable, maintainable, and adheres to the best coding practices and standards.



  • Refactoring: Improving the Design of Existing Code by Martin Fowler: This is a book that teaches you how to improve the design and quality of your code by applying various refactoring techniques and patterns.