I hear that TDD is a very useful practice, yet no team I've worked on (so far) has pushed its use. I was introduced to it by Dave Farley, and ever since I've been hooked. There are no silver bullets, but that doesn't mean we shouldn't strive to do better.
- Test Behavior, not Implementation: "Tests should be coupled to the behavior of code and decoupled from the structure of code." Quoting Kent Beck. Write tests only against the stable contract of a public API.
- The unit of Isolation is the Test, NOT the thing under Test: If you are mocking every dependency of a class because 'that is a proper unit test' you are wrong. The unit of isolation is the test, not the thing under test. If you touch a database for example, isolation means making sure the changes from test #1 don't impact test #2.
- Requirements Drive Tests: The trigger for a new test, is that you have a new requirement. Do not write tests per class or per function.
- Testable Code is Decoupled: When tests are a part of your process, you are forced to write testable code. Testable code is less coupled code. If creating tests is painful for you, it is not the tests that are at fault.
- Work in Small Steps: A large step is exponentially (not linearly) more complex than several small steps, even if the destination is the same.
- Given, When, Then: Given X, When I do Y, Then I have Z. This is one example of how to write a test.
- Behavior Driven Development: An easier way to think about TDD is to think of it as Behavior Driven Development (a case of words mean things). There's a behavior in the system, and we want to use code to prove the behavior exists in the system. Not that we need 100%-unit test coverage.
- Fast Feedback, Fast Refactor: Tests have to run fast, otherwise Developers don't receive Fast Feedback. It must also be easy to refactor.
- Red, Green, Refactor: Red - Write a little test that doesn't work (or maybe doesn't even compile), Green - Get the test working, committing any sins necessary in the process, Refactor - Now, make good code. If Green is the 'Duct Tape Programmer' response, Refactor is the Clean Code follow-up. No new tests during Refactoring.
Bad: Testing Anti-pattern "Ice Cream Cone"
Good: Ideal Software Testing Pyramid
🔥TDD, Where Did it All Go Wrong?
This really helped clear up my misconceptions about TDD:
🔥TDD Revisited
🔥TDD Reduces Stress
TDD is the reason I'm never stressed, always feel confident that things will work and also why I get frustrated at the industry so much, because this technique works beautifully, and it should be a standard by now. - Paul Hammond
Sage's Bookshelf
This is the grab bag of cool things.
📖 Rosenblatt AI: Apple's Senior Director of ML & AI revealed expected savings of roughly 50% with new Trainium2 chips (Some great insights and a focus on a core driver of AI: the cost of chips)
📖 Full Stack Tools & Techniques Analysis: Thoughtworks Technology Radar is a twice-yearly snapshot of tools, techniques, platforms, languages and frameworks (Some great insights into the tech landscape)
📖 AI: ChatGPT Assistants API (Can run code in a Python Interpreter, execute external functions, perform basic Retrieval Augmented Generation (RAG), and more)
📖 Kubernetes: We are Leaving Kubernetes (Yet another 'work backwards from the user' situation, the dev environment should receive intentional Design too)
📖 Hexagonal Architecture: AWS Guide to Implementing Hexagonal Architecture in the Cloud (You can find a bunch of Architecture patterns in the menu to the left on this page)
📖 AI Tool: Scrapybara (Deploy AI Agents with Computer Use to VMs in Scale)
📖 Microservices: Don't Build a Distributed Monolith (Again, do not build a Distributed Monolith)
📖 Defcon: Fake Science Factories (Many, many people and organizations rely on scientific studies to base decision-making. It shouldn't surprise anyone that efforts exist to influence that decision-making towards various goals.)
Building AI: Interested in help building AI? Check out Rosenblatt AI via Website, or check out the Upwork. Let them know I sent you. :)
#startup #cto #ceo #fullstack #fullstackengineering #softwareengineering