logoalt Hacker News

chrisoverzeroyesterday at 9:33 PM1 replyview on HN

Sure! Let’s say I want to enforce that a variable only ever holds an integer. Rather than put the conventional prefix and the name together, like this:

    var intValue = 3;
…I separate the conventional prefix with a space:

    int value = 3;
…so now my co-workers don’t need to remember the convention – it’s enforced by the language.

(I hope this makes the joke more obvious.)


Replies

conartist6yesterday at 10:51 PM

I wasn't talking about Hungarian notation. I meant more like if you see a variable named `user` or `activeUser` you know that it's going to contain a predictably-shaped data object that describes a user. E.g. it will always have a `user.id` property. I would never call an string-ish ID a user, then. I would call it `activeUserId` or `userId` or just `id` if the distinction between those was already obvious from context... But that's very different from writing `strUserId` which I never do: I try to make sure my names always convey semantic distinctions.

show 1 reply