Remix.run Logo
qouteall 2 hours 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".

pveierland 28 minutes ago | parent | next [-]

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 15 minutes ago | parent [-]

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.

throwaway2027 2 hours ago | parent | prev [-]

Isn't that more tokens though?

post-it 35 minutes ago | parent | next [-]

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

0x457 2 hours ago | parent | prev | next [-]

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 2 hours ago | parent | prev [-]

Not significantly, it's one word.