Naming - compress-and-get-payload

36 views
Skip to first unread message

Juraj Martinka

unread,
Feb 21, 2019, 2:33:17 AM2/21/19
to Elements of Clojure
Hi,
I've read the Names chapter recently and one thing that seems wrong to me is the `compress-and-get-payload` function name on page 19.
To me, this implies that "something" is first compressed and then the payload is fetched so I'd rather choose `get-and-compress-payload` or `get-payload-and-compress`.
What do you think about this?

Juraj Martinka

unread,
Feb 22, 2019, 2:57:47 AM2/22/19
to Elements of Clojure
I hope it's okay to share my conversation with Zach here which makes it clear why the function is called `compress-and-get-payload` (because the compression happens outside the process)

In the described function, the stored payload is being replaced by its compressed form outside the process, and then that compressed form is pulled into the process. Given that, does the name make more sense?


On Thu, Feb 21 2019 at 11:24 PM, Juraj Martinka wrote: 
Hi Zach,
thanks for the response.
I think that was clear - I got it that the returned response is a compressed version of the payload.
The reason why I suggested the `get-and-compress-payload` is because it's more aligned with what the code is doing - first it fetches the payload and then it compresses it; then it's returned to the client


On Fri, 22 Feb 2019 at 01:27, Zach Tellman wrote:
The full sentence in question is this:

If it takes an `id`, replaces the payload with a compressed version, and returns the result, it should be called `compress-and-get-payload`. 

Maybe this was unclear, but the "result" here is meant to be the compressed version of the payload.  The functionality I'm describing does align with your intuition of what the name should describe.  

Hope that helps,
Zach

Reply all
Reply to author
Forward
0 new messages