Re: [hackers] [libgrapheme] Rename API functions to improve readability || Laslo Hunhold

From: NRK <nrk_AT_disroot.org>
Date: Tue, 21 Dec 2021 01:39:23 +0600

> The solution is to loosen the naming a bit and not require the
> "component" (in this case "character") to immediately follow the
> "grapheme_" prefix. Instead, the "is" and "next" keywords are brought
> to the front, which improves the readability substantially and the
> functions are well-grouped into "is" and "next" functions.
>
> Analogously, it makes more sense to "decode_utf8" than "utf8_decode",
> so this was changed as well, including going back to
> GRAPHEME_INVALID_CODEPOINT, which just rolls off the tongue better.

Hi Laslo,

It is true that verb followed by noun is more "natural" sounding , eg.
"Get that pen." However when it comes to functions naming, I prefer
having the noun/object first.

The reasoning here is when writing code, I don't think, "Hmm, I want to
do something and I want that something to be done on that object." No,
my thought process is more in line with "I have this object, and I want
to perform this action on it."

Although this probably doesn't apply in this case, but one other benefit
of this naming scheme is that functions are grouped together more nicely
based on what they operate on. Eg. when typing "lib_objX" you will get
all the actions you can perform on objX.

Of course, I'm not claiming that everyone else's thought process is the
same as mine. Nor am I asking the naming to be changed in this case. But
rather, I'm simply providing some food for thought by explaining my
rational on why I believe having object first is better for function
naming.

- NRK
Received on Mon Dec 20 2021 - 20:39:23 CET

This archive was generated by hypermail 2.3.0 : Mon Dec 20 2021 - 20:48:31 CET