Hacker News new | past | comments | ask | show | jobs | submit login

I’m working daily on a pretty large, gnarly, legacy monolith, and consequently been thinking a lot about approaches to refactoring when I came across a (ruby) library called Suture [1].

It allows you to perform black-box testing, recording and replaying test data (gathered from production).

From there you can refactor your code and even have the library run both new/old codepaths in production, raising errors if there is a mismatch.

To your point about constant rewrites, I think using a library like this while continuously refactoring existing code is a pretty exciting idea.

Too bad I need a Java version (maybe a good idea for a side-project).

[1] https://github.com/testdouble/suture




I recently learned from Tristan’s blog [1] about a similar feature in Rust [2]. I can’t wait to try it out.

[1] http://thume.ca/2019/04/18/writing-a-compiler-in-rust/ [2] https://github.com/mitsuhiko/insta


Have your test and not write it too.

Very appealing, but one problem I've found with this general idea is equivalent but non-identical results. A simply-solved example is a serialized set: different orderings differ, but are equivalent. You can get more complex ones, such as ASTs ax+bx and (a+b)x.

Such cases should be pretty rare, but they come up for me all the time.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: