From: Junio C Hamano <gitster@pobox.com>
To: Taylor Blau <me@ttaylorr.com>
Cc: karthik nayak <karthik.188@gmail.com>,
Patrick Steinhardt <ps@pks.im>,
git@vger.kernel.org
Subject: Re: [PATCH] CodingGuidelines: discourage arbitrary suffixes in function names
Date: Wed, 23 Oct 2024 17:50:17 -0700 [thread overview]
Message-ID: <xmqqr086pbna.fsf@gitster.g> (raw)
In-Reply-To: <ZxfVwQxMlcJbGt5D@nand.local> (Taylor Blau's message of "Tue, 22 Oct 2024 12:41:37 -0400")
Taylor Blau <me@ttaylorr.com> writes:
> I don't disagree that writing "single" or "recursively" can be
> considered clearer. I think that the convention to suffix such functions
> with "_1()" is more terse, but saves characters and can avoid awkward
> line wrapping.
I am reasonably sure that I was the first user of the _1()
convention, or at least I was one of them. The reason for the
choice of suffix was only because there wasn't anything suitable
when refactoring an existing function foo() into a set-up part and
its recursive body, so I just kept the set-up part and the single
call into the new function in the original foo(), and had to give a
name to the new function that holds the body of the original logic
that was moved from foo().
Neither foo_helper() or foo_recursive() were descriptive enough to
warrant such longer suffixes than a simple _1(). They easily can
get "help by doing what?" and "recursively doing what?" reaction,
which is a sure sign that the suffixes are not descriptive enough.
That was the only reason why I picked that "short-and-sweet but
cryptic" suffix.
Surely all of _1(), _helper(), _recursive() are meaningless. If we
were to replace existing uses of them, the replacement has to be 10x
better.
Having said all that, as an aspirational goal, I think it is good to
encourage people to find a name that is descriptive when writing a
new function. I'd refrain from judging if it is way too obvious to
be worth documenting (as I am officially on vacation and shouldn't
be thinking too much about the project).
Thanks.
next prev parent reply other threads:[~2024-10-24 0:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-21 12:41 [PATCH] CodingGuidelines: discourage arbitrary suffixes in function names Karthik Nayak
2024-10-21 12:59 ` Patrick Steinhardt
2024-10-21 20:02 ` Taylor Blau
2024-10-22 8:45 ` karthik nayak
2024-10-22 16:41 ` Taylor Blau
2024-10-23 7:44 ` karthik nayak
2024-10-24 0:50 ` Junio C Hamano [this message]
2024-10-24 16:50 ` Taylor Blau
2024-10-22 8:34 ` karthik nayak
2024-10-21 16:51 ` Kristoffer Haugsbakk
2024-10-22 8:47 ` karthik nayak
2024-10-23 7:57 ` [PATCH v2] " Karthik Nayak
2024-10-23 20:34 ` Taylor Blau
2024-10-23 21:03 ` Karthik Nayak
2024-10-23 23:07 ` Justin Tobler
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=xmqqr086pbna.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=karthik.188@gmail.com \
--cc=me@ttaylorr.com \
--cc=ps@pks.im \
/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).