← Back to context

Comment by eru

6 hours ago

I agree with you. However the grand-parent comment has a point that it's not easy to extract testable properties from code that's already written.

It's much easier to proceed explicitly like you suggest: have some properties in mind, co-develop property tests and code.

Often when I try to solve a problem, I start with a few simple properties and let them guide my way to the solution. Like your deletion example. Or, I already know that the order of inputs shouldn't matter, or that adding more constraints to an optimiser shouldn't increase the maximum, etc.

And I can write down some of these properties before I have any clue about how to solve the problem in question.

---

However, writing properties even after the fact is a learnable skill. You just need to practice, similarly to any other skill.