logoalt Hacker News

arjietoday at 12:32 AM4 repliesview on HN

In order to make it work without polluting the code-base I find that I have to move the persistence into injectable strategy, which makes it good anyway. If you keep passing in `if dry_run:` everywhere you're screwed.

Also, if I'm being honest, it's much better to use `--wet-run` for the production run than to ask people to run `--dry-run` for the test run. Less likely to accidentally fire off the real stuff.


Replies

wgingtoday at 1:57 AM

One nice way to do things, if you can get away with it, is to model the actions your application takes explicitly, and pass them to a central thing that actually handles them. Then there can be one place in your code that actually needs to understand whether it's doing a dry run or not. Ideally this would be just returning them from your core logic, "functional core, imperative shell" style.

show 1 reply
ryandraketoday at 2:08 AM

I don't want to have to type rm --wet-run tempfile.tmp every time, or mkdir -p --yes-really-do-it /usr/local/bin

The program should default to actually doing whatever thing you're asking it to do.

On the other hand it would be great if every tool had an --undo argument that would undo the last thing that program did.

show 2 replies
sh-runtoday at 2:02 AM

I don't like the sound of `--wet-run`, but on more than one occasion I've written tools (and less frequently services) that default to `dry-run` and require `--no-dry-run` to actually make changes.

For services, I prefer having them detect where they are running. Ie if it's running in a dev environment, it's going to use a dev db by default.

segmondytoday at 12:45 AM

this is where design patterns come in handy even tho folks roll their eyes at it.

show 2 replies