News for hackers. Stuff that matters.
Re:Scientist: A Ruby library for carefully refactoring criti... by jamesfzhang on Sunday November 10, 2019 @01:16PM (#21499273)
I've use Scientist for every major refactor I've done--IMO it's one of the best examples of a library that does one thing extremely well and has a clean interface.
Re:Scientist: A Ruby library for carefully refactoring criti... by Manfred on Sunday November 10, 2019 @08:31AM (#21497884)
Feeding production data into two different paths to compare them is obviously valuable. Does anyone have any good reasons why this has to happen in online code and can't happen against database replicas in offline mode?

I always feel that it would be great to be able to do this with code that has side-effects (eg. anything that changes the database) but I've never seen a general purpose solution for this. The README mentions using a write replica, but how do you deal with data drifting in case of bad writes?

Re:Scientist: A Ruby library for carefully refactoring criti... by jauco on Sunday November 10, 2019 @01:06PM (#21499220)
There’s goreplay[0]. But once you start using that you quickly find that many parts of your app use random data (such as uuids) or clock data (timestamps etc) getting these synced between prod and replay or ignored on replay is quite a hassle.

[0]: https://goreplay.org/

Re:Scientist: A Ruby library for carefully refactoring criti... by dyeje on Sunday November 10, 2019 @09:52AM (#21498130)
They wrote a good blog post about using this gem back in 2016: https://github.blog/2016-02-03-scientist/
Re:Scientist: A Ruby library for carefully refactoring criti... by FrancoisBosun on Sunday November 10, 2019 @09:10AM (#21497997)
Maybe because of the large increase in complexity?
Re:Scientist: A Ruby library for carefully refactoring criti... by hamandcheese on Sunday November 10, 2019 @03:24PM (#21499969)
Another possibility might be to do the side effects in a transaction that gets rolled back?
Re:Scientist: A Ruby library for carefully refactoring criti... by aflag on Sunday November 10, 2019 @04:30PM (#21500312)
How to handle the case when you want to replace a function that makes changes to a database? Is this library aimed only towards functions which don't make changes to the system's state?
Re:Scientist: A Ruby library for carefully refactoring criti... by blairanderson on Sunday November 10, 2019 @05:07PM (#21500469)
How would you handle this case WITHOUT this library?
Re:Scientist: A Ruby library for carefully refactoring criti... by aflag on Monday November 11, 2019 @02:52AM (#21502941)
I'm not experienced in running live experiments. So, I don't know.
Re:Scientist: A Ruby library for carefully refactoring criti... by tobyhinloopen on Sunday November 10, 2019 @10:28AM (#21498311)
Alternative title: “Scientist: A Ruby library for changing production code while still not having to write tests”
Re:Scientist: A Ruby library for carefully refactoring criti... by hinkley on Sunday November 10, 2019 @11:26AM (#21498622)
In TDD they might call these pinning tests.

This kind of testing isn’t just good for refactors. You can also use it for rewrites or substantial architectural changes. I think github did something like this while trying to make the storage format more efficient.

Re:Scientist: A Ruby library for carefully refactoring criti... by jbarnette on Sunday November 10, 2019 @06:46PM (#21500981)
By the time we extracted Scientist, the code we were refactoring had pretty good test coverage. But even the best test suite is an imperfect model of production. The first section of the README briefly mentions this:

"Let's pretend you're changing the way you handle permissions in a large web app. Tests can help guide your refactoring, but you really want to compare the current and refactored behaviors under load."

Re:Scientist: A Ruby library for carefully refactoring criti... by Xylakant on Sunday November 10, 2019 @05:01PM (#21500444)
Even in a well-tested codebase some integration points are extremely hard to test, notably external services that you connect to. Rewriting these to use a different service or just a different way of connecting to a service would be an example where this ends up being useful.
Re:Scientist: A Ruby library for carefully refactoring criti... by hamandcheese on Sunday November 10, 2019 @03:28PM (#21499998)
Which is really valuable if you don’t have tests, or your test suite doesn’t give you much confidence, is too brittle to make the changes without breaking the tests, or maybe the code is structured so that it’s really hard to test all the paths that occur in production.
Re:Scientist: A Ruby library for carefully refactoring criti... by ydnaclementine on Sunday November 10, 2019 @09:45AM (#21498099)
Using this at work last week to refactor a database call to a new service call
Re:Scientist: A Ruby library for carefully refactoring criti... by sentrysapper on Sunday November 10, 2019 @05:17PM (#21500530)
is there a library like this for PHP?
Re:Scientist: A Ruby library for carefully refactoring criti... by e12e on Sunday November 10, 2019 @05:19PM (#21500550)
[dead]
Re:Scientist: A Ruby library for carefully refactoring criti... by dang on Sunday November 10, 2019 @03:15PM (#21499909)
"Please don't post shallow dismissals, especially of other people's work. A good critical comment teaches us something."

https://news.ycombinator.com/newsguidelines.html

Re:Scientist: A Ruby library for carefully refactoring criti... by nchase on Sunday November 10, 2019 @05:25PM (#21500583)
https://www.npmjs.com/package/scientist

Is it this one, or another?