logoalt Hacker News

qoutealltoday at 5:05 AM3 repliesview on HN

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".


Replies

groundzeros2015today at 7:41 AM

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

pveierlandtoday at 6:48 AM

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.

show 1 reply
throwaway2027today at 5:33 AM

Isn't that more tokens though?

show 3 replies