Coach Denis - Test-driven Development 2023 (Re 2)
Coach Denis - Test-driven Development 2023 (Re 2)
Test-Driven Development
Booklet
By Denis Čahuk, Revision 2
Who is this booklet for?
This booklet is best suited for software engineers,
developers, technologists, tech leaders and managers as well
Introduction as students and amateurs wanting to step into this field.
Important: Start with your least complex test first and iterate by gradually
increasing complexity - this step is critical for reducing unnecesary, accidental
over-architecting
2 Explore
Nothing more.
If 'return 5' passes all tests, then write that.
Design improvement:
Refactor
🤚 Changing the public API of your method, class or module is NOT refactoring.
🔥 𝐘𝐨𝐮 𝐜𝐚𝐧 𝐭𝐡𝐫𝐨𝐰 𝐭𝐡𝐞 𝐬𝐢𝐥𝐥𝐲 𝐞𝐚𝐫𝐥𝐲 𝐭𝐞𝐬𝐭𝐬 𝐚𝐰𝐚𝐲
🔧 Simplify tests as part of the refactoring step
Embrace Modularity /
Tactical Domain Driven
Design
TDD x DDD
The design aspect of TDD is oft-overlooked.
TDD done well is a high bar if good design and domain understanding is
alien to the engineer.
Value Objects - object types using nouns from the ubiquitous language to
promote primitives and anonymous types into more concrete values.
Treat them as immutable and without identity (compare based on
attributes)
Domain Events - the expression of side effects within your domain. Can
be used for decoupled messaging and event sourcing.
Domain-Driven Design - Layers
Application
Communicates with Services, and Factories to access Aggregate Roots.
This is where frameworks are most practical.
Domain
This is where your revenue-producing business logic lives. Your main
TDD activity goes here. The bulk of your tests go here.
Infrastructure
Persistence, communication, databases, security. Contrary to popular
belief - if using a PostgreSQL is a business and domain decision,
abstract the connection from the domain, but not the type (or queries)
Why does all of this DDD
detail matter?
The ROI on adopting TDD is low maintenance
costs by providing high modularity and retain
testability.
1 2
Transformations are the act of adding features and behaviour to the system.
Refactorings are the act of changing implementation without altering behaviour.
👉
💚 Tests are the engineer's responsibility. It's about
cost-saving, safety and reliability.
👉
💚 When you're doing testing and you also want to
learn TDD, don't go all in.
👍
Chapter 9
Resources
THE
Book
that started everything
About me
Hi, my name is Denis Čahuk, but
you may know me as Coach Denis.
sourcing.
I'm meeting with my photographer next week.
🎙 The Technologist
Podcast
The Technologist Podcast is where
we discuss all matters of being a
Technologist.
🔗For B2B services for your company, contact me directly via email
[email protected]
🔗Accelerate your mastery with my TDD workshop
🔗Hire me for long-term 1on1 Mentoring
Chapter 11
Thanks and
Acknowledgements
Thanks to the early adopters, supporters and enthusiasts who gave feedback and made
this booklet grow from the initial few pages:
·
Siddhart R. C. · Habibellah A. · Kishore K. A. · Dragos R. · Shahriyar R. · Ryan D. · Joost D. ·
Nikolina G. · Lucas L. · Peter S. · Slavomir P. · Deepak S. · Gourav S. · Hussein E. · Jacobus
M. · Fawwad K. · Edouard M. · R Kaja M. · Neel D. · Marcelo C. · Jaime B.C. · Kaivalya A. ·
Prashant B. · Sabahudin K. · Siddhart S. · Russel S. · Jason C. · Torben H. · Vladi I.
·
Special thanks to Nik Sumeiko, Jay Desai, Jason Gorman, Valentina Cupać, Richard
Dyce, Oliver Zihler, Taj Pelc, Jonathan Stark and Sander Hoogendoorn for the long
conversations and encouragement that made all of this possible.
·
Finally, I can't express in words the magnitude of joy, gratitude and inspiration I received
from my beautiful and courageous partner, Asja, and our two kids, Luna and Gaja, who
inspire me on a daily basis and support me so perfectly in opening up to even more
challenges and opportunities in my life.
I would love to hear your
success and failure stories
Got a hard-to-test system?
Shoot me an email: [email protected] 📧
Share this booklet with your
friends and coworkers!