From: Karthik Nayak <karthik.188@gmail.com>
To: karthik.188@gmail.com
Cc: git@vger.kernel.org, ps@pks.im, me@ttaylorr.com,
kristofferhaugsbakk@fastmail.com
Subject: [PATCH v2] CodingGuidelines: discourage arbitrary suffixes in function names
Date: Wed, 23 Oct 2024 09:57:06 +0200 [thread overview]
Message-ID: <20241023075706.1393147-1-karthik.188@gmail.com> (raw)
In-Reply-To: <20241021124145.636561-1-karthik.188@gmail.com>
We often name functions with arbitrary suffixes like `_1` as an
extension of another existing function. This creates confusion and
doesn't provide good clarity into the functions purpose. Let's document
good function naming etiquette in our CodingGuidelines.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
Documentation/CodingGuidelines | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 30fda4142c..635d6f3a27 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -621,6 +621,24 @@ For C programs:
- `S_free()` releases a structure's contents and frees the
structure.
+ - Function names should be self-explanatory, clearly reflecting their
+ purpose or behavior.
+
+ The '_1' suffix for function names has historically indicated:
+
+ - functions processing one of several elements that all need to be
+ handled similarly.
+
+ - recursive functions that need to be separated from a setup stage.
+
+ To maintain clarity and avoid confusion, such arbitrary suffixes are
+ discouraged, as they provide no meaningful insight into the function's
+ role.
+
+To maintain clarity and avoid confusion,
+ arbitrary suffixes such as _1 are discouraged, as they provide no
+ meaningful insight into the function's role.
+
For Perl programs:
- Most of the C guidelines above apply.
Range-diff against v1:
1: 0acdf6902c ! 1: dd556a8029 CodingGuidelines: discourage arbitrary suffixes in function names
@@ Commit message
CodingGuidelines: discourage arbitrary suffixes in function names
We often name functions with arbitrary suffixes like `_1` as an
- extension of another existing function. This created confusion and
+ extension of another existing function. This creates confusion and
doesn't provide good clarity into the functions purpose. Let's document
good function naming etiquette in our CodingGuidelines.
@@ Documentation/CodingGuidelines: For C programs:
structure.
+ - Function names should be self-explanatory, clearly reflecting their
-+ purpose or behavior. To maintain clarity and avoid confusion,
++ purpose or behavior.
++
++ The '_1' suffix for function names has historically indicated:
++
++ - functions processing one of several elements that all need to be
++ handled similarly.
++
++ - recursive functions that need to be separated from a setup stage.
++
++ To maintain clarity and avoid confusion, such arbitrary suffixes are
++ discouraged, as they provide no meaningful insight into the function's
++ role.
++
++To maintain clarity and avoid confusion,
+ arbitrary suffixes such as _1 are discouraged, as they provide no
+ meaningful insight into the function's role.
+
--
2.47.0
next prev parent reply other threads:[~2024-10-23 7:57 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
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 ` Karthik Nayak [this message]
2024-10-23 20:34 ` [PATCH v2] " 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=20241023075706.1393147-1-karthik.188@gmail.com \
--to=karthik.188@gmail.com \
--cc=git@vger.kernel.org \
--cc=kristofferhaugsbakk@fastmail.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).