-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
I find `push` is easier to read this way. push_bulk is quite complex and adds a net-negative layer of abstraction.
- Loading branch information
There are no files selected for viewing
2 comments
on commit ba557da
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😢 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, I'm unhappy any time I have to roll back changes which someone kindly contributed but my #1 concern for the code is always my own ability to understand and maintain it long-term. It's quite common for me to rewrite code that I get into my "style" so that I can better understand it and read it going forward.
Regarding generate_jid
, there's no reason from my POV to extract this into its own tiny method. We're not going to change how JIDs are generated, I don't want to make it easy for people to change it (i.e. by extracting a method you allow others to easily monkeypatch it), it does add a tiny bit of runtime overhead and the impl itself is so straightforward that it doesn't hide any complexity. DRY is a concern but two copies isn't enough to justify.
Contrary to what was "idiomatic" Ruby a decade ago, I prefer classes which don't have lots of tiny extracted methods. I prefer a few big methods where I can "see" everything that is going to happen, rather than lots of jumping around between dozens of methods. I find it keeps the cognitive overhead low. S::Processor#process is a good example, it encapsulates the steps necessary to process a job, with just one significant extracted method dispatch
(execute_job
is extracted for testing).
https://github.com/mperham/sidekiq/blob/main/lib/sidekiq/processor.rb#L145
This is the change that I can't really understand.
generate_jid
explains what the method does. You're going back to duplication. It's just in two places, but every time I seeSecureRandom.hex(12)
my brain has to pause for a second to think about the purpose of the code.