top | item 47097687

(no title)

qouteall | 10 days ago

With modern IDE and AI there is no need to save letters in identifier (unless too long). It should be "sizeInBytes" instead of "size". It should be "byteOffset" "elementOffset" instead of "offset".

discuss

order

pveierland|10 days ago

When correctness is important I much prefer having strong types for most primitives, such that the name is focused on describing semantics of the use, and the type on how it is represented:

    struct FileNode {
        parent: NodeIndex<FileNode>,
        content_header_offset: ByteOffset,
        file_size: ByteCount,
    }
Where `parent` can then only be used to index a container of `FileNode` values via the `std::ops::Index` trait.

Strong typing of primitives also help prevent bugs like mixing up parameter ordering etc.

kqr|10 days ago

I agree. Including the unit in the name is a form of Hungarian notation; useful when the language doesn't support defining custom types, but looks a little silly otherwise.

groundzeros2015|10 days ago

Long names become burdensome to read when they are used frequently in the same context

ivanjermakov|10 days ago

When the same name is used a thousand times in a codebase, shorter names start to make sense. See aviation manuals or business documentation, how abbreviation-dense they are.

layer8|10 days ago

When you’re juggling inputBufferSizeInBytes, outputBufferSizeInBytes, intermediateRepresentationBufferSizeInBytes, it becomes unwieldy and cumbersome.

I once had a coworker like that, whose identifiers often stretched into the 30-50 characters range.You really don’t want that.

throwaway2027|10 days ago

Isn't that more tokens though?

post-it|10 days ago

Only until they develop some kind of pre-AI minifier and sourcemap tool.

0x457|10 days ago

Sure you get one or two word extra worth of tokens, but you save a lot more compute and time figuring what exactly this offset is.

Onavo|10 days ago

Not significantly, it's one word.