Stephen FoX
145 posts

Stephen FoX रीट्वीट किया
Stephen FoX रीट्वीट किया

@housecor At first you should be writing down a list of behaviours you want your code to achieve. That limits what your API can become and that’s where TDD comes in
English

TDD Made Intuitive: Spec-First Thinking
Why we should embed spec in our workflow.
Test-driven development (TDD) is often rejected due to its perceived unintuitiveness. Is there a way to make TDD more intuitive? I believe there is, and it requires us to think more about specification first, rather than testing first.
In this essay, I’ll explain why spec-first might be more intuitive than test-first. I’ll further explore why we still don’t write a spec even though it’s an intuitively small yet impactful step, with the hope that more of us will think about this in our work.
Spec first, test last
I previously wrote about how unintuitive TDD might be for some. The root of the unintuitiveness of TDD comes from the word test:
> The idea of test to be after the fact is simple enough for even young children to grasp. They are tested, once they have studied. They got tested for an illness, once there’s a symptom for it. They can test a dish, once it’s started cooking. Testing, always comes last, not first!
Let’s consider the term “spec” instead. The terms specification, specify, and specific all stem from the Latin word “specificus”, which pertains to defining or identifying with clarity. You make something specifically clear by specifying in a specification.
The idea of specifying is simple enough for young children to grasp, even when they don’t use the word spec. The recipe they follow to cook is a spec. Builders don’t start laying bricks randomly; they follow a spec. Before you are about to drive that nail to the wall, you mark the spot first (spec). Spec mostly comes first, not last.
In the TDD process, one might view the first step more as defining a specification than merely setting up a test. Some of you might be creating spec files without realising why it’s called this way, i.e. foo.spec.js or foo_spec.rb. The next time you write that spec file, think about it for a moment: why is it called a spec?
When you think in spec-first, a specification is the defined behaviour of the elements you’re about to create.
As I have described so far in this series, the benefits of TDD hinge on the concept of laying out specifications. I believe you’ll gain the benefit even when you don’t write the spec in code. Write spec in human language if you feel that it’s easier. TDD helps you save one step by encouraging you to write the specification in code.
Unfortunately, although the word spec should intuitively come first before coding, we still don’t intuitively spec first. Knowing is not enough, we tend to miss this step.
Coding mindlessly
Seth Godin frequently emphasises the significance of specifications in his writings. In his blog post, Creating a useful spec, he wrote: ........
....
(Finish your 6m reading / 8m listening here:
read.ceilfors.com/p/tdd-made-int…)

English

@adelindev @ceilfors @KentBeck It’s the definition of a classic. It never needs updating as it’s all in there, lots to unpack.
English

@Foxman I didn't realise that TDD describes a to-do list of behaviours. Do you have any references I could look at? Thanks!
English

@MONSTERBRYTON @zerochills Dude did not die he actually left the seen and refused EMS help. Employee was not arrested. Taco bell defended the employee and said no further action will be taken. Clear case of self defense. BTW this was in Wales UK
English

@davidsmorais @epoch_rift @vitest_dev Just read your article. Good stuff. Would say that using TDD to test a framework is kinda of an anti-pattern, should only be using TDD for code you write as have to assume the framework has its own test suite. Far less frustrating using it only on what you own
English

I'm not the greatest fan of test driven development, but I'm using it to build my game, @epoch_rift .
I wrote an article on how I'm using @vitest_dev to write game logic for my game, check it out 👇
dev.to/davidmorais/te…
#javascript #typescript #developers #frontenddev
English

I don't know if I've discovered the "secret" to entrepreneurship, but I've certainly learned plenty of lessons along the way. Had a lot of fun reminiscing with @tomfoster2 and walking through what we're building @wonder. Thanks @Inc!
Inc.@Inc
Has @MarcLore discovered the secret to entrepreneurship? This visionary, tactician, operator, disrupter, competitor, and former track star has won many ways--and always with speed. on.inc.com/9H8Dbue. The magazine will be on newsstands December 13.
English

tidyfirst.substack.com/p/sources-of-f… What a joy to start writing the second software design book assuming that people know the concepts & vocabulary from Tidy First?. #NoPaywall
English

@talkSPORT listening to Stuart Pearce confidence in England slowly ebb away… hahaha
English

@unclebobmartin is there example code for the ‘GUI’ data object -> request model/event handler around anywhere?
English

@Foxman The base class has no public methods. The inheritance in that case is really just a shorthand for composition.
English

@unclebobmartin I'm reading the refactoring chapter in #cleancraftsmanship and your example using the csv/report builder has me confused. You split a class into two where one inherits from the other, isn't this a Liskov Substitution Principle no-no?? Please enlighten.
English








