From: Junio C Hamano <gitster@pobox.com>
To: Lucas Oshiro <lucasseikioshiro@gmail.com>
Cc: git@vger.kernel.org, kernel-usp@googlegroups.com,
rcdailey.lists@gmail.com, me@ttaylorr.com, peff@peff.net,
matheus.bernardino@usp.br,
"Bárbara Fernandes" <barbara.dcf@gmail.com>
Subject: Re: [RFC WIP PATCH 2/3] tag: factor out prepare tag template code
Date: Thu, 10 Oct 2019 13:29:47 +0900 [thread overview]
Message-ID: <xmqqftk1jk90.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <xmqqo8ypjota.fsf@gitster-ct.c.googlers.com> (Junio C. Hamano's message of "Thu, 10 Oct 2019 11:51:13 +0900")
Junio C Hamano <gitster@pobox.com> writes:
> Lucas Oshiro <lucasseikioshiro@gmail.com> writes:
>
>> Improve code readability by moving tag body reading to a new function called
>> get_tag_body.
>
> Quite honestly, I think the result of this splitting is harder to
> follow than the original.
>
> For example, the value of opt->message_given and the validity of
> given_msg is very closely related, so if you made the helper
> function receive non-NULL given_msg when !opt->message_given, the
> helper could only check !given_msg without having to worry about
> opt->message_given; with such a change, I could buy that the split
> improves code readability, but I do not see any such change in the
> patch.
Just to avoid misunderstanding, I am not suggesting to change the
interface into the helper you introduced to be like this
prepare_tag_template(opt->message_given ? buf, NULL,
opt, prev, path, tag);
That still needs to pass the entire opt structure into the helper
and forces the helper to look at opt->cleanup_mode and behave
differently. If a restructuring of the code can be done in such a
way that the helper no longer need to look at opt (hence no need to
pass the entire opt structure into it), I can see that the change
improves the readability of the resulting code, but I am not all
that hopeful.
On the other hand (and this is the more important hand among the two
;-), I do not mind splitting a helper function out of an existing
codepath and make the existing codepath call the new helper, so that
the same helper can be reused from another codepath later. Not at
all. What I do mind is to mislabel a change that is done for such a
later code reuse as one that improves readability, when it does not.
Thanks.
>> Enhance legibility by encapsulating code that loads previous tag message
>> (if any) in new function prepare_tag_template....
>
> The helper seems to be used to _write_ into path, and not load or
> read any message from either an object or a file on disk.
next prev parent reply other threads:[~2019-10-10 4:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-08 18:47 [RFC WIP PATCH 0/3] tag: fix --edit and --no-edit flags Lucas Oshiro
2019-10-08 18:47 ` [RFC WIP PATCH 1/3] tag: factor out tag reading from write_tag_body() Lucas Oshiro
2019-10-09 1:48 ` Matheus Tavares Bernardino
2019-10-10 2:42 ` Junio C Hamano
2019-10-08 18:47 ` [RFC WIP PATCH 2/3] tag: factor out prepare tag template code Lucas Oshiro
2019-10-09 3:02 ` Matheus Tavares Bernardino
2019-10-10 2:51 ` Junio C Hamano
2019-10-10 4:29 ` Junio C Hamano [this message]
2019-10-08 18:47 ` [RFC WIP PATCH 3/3] tag: add full support for --edit and --no-edit Lucas Oshiro
2019-10-09 9:19 ` Matheus Tavares Bernardino
2019-10-10 3:34 ` Junio C Hamano
2019-10-10 2:13 ` [RFC WIP PATCH 0/3] tag: fix --edit and --no-edit flags Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqftk1jk90.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=barbara.dcf@gmail.com \
--cc=git@vger.kernel.org \
--cc=kernel-usp@googlegroups.com \
--cc=lucasseikioshiro@gmail.com \
--cc=matheus.bernardino@usp.br \
--cc=me@ttaylorr.com \
--cc=peff@peff.net \
--cc=rcdailey.lists@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).