|
|
|
|
|
by mr_mitm
542 days ago
|
|
Why not just do something like this then? This: myfunction(data) {
# do one thing to the data
...
# now do another
...
}
becomes that: myfunction(data) {
do_one_thing_to_the_data(data)
now_do_another(data)
}
do_one_thing_to_the_data(data) {
...
}
now_do_another(data) {
...
}
Still linear, easier to get an overview, and you can write more modular tests. |
|
Plus, if we're dealing with a "long list of tasks" that can't be broken up in reusable chunks, it probably means that you need to share some context, which is way easier to do if you're in the same scope.
One thing I find useful is to structure it in blocks instead, so you can share things but also contain what you don't want shared. So e.g. in rust you could do this:
I think it's a nice middleground. But you still can't write modular tests. But maybe you don't have to, because again, this is just a long list of tasks you need to do that conceptually can't be broken down, so maybe it's better to just test the whole thing as a unit.