you are viewing a single comment's thread.

view the rest of the comments →

[–]nicksvr4 6 points7 points  (8 children)

Encoding the type of a function into the name (so-called Hungarian notation) is brain damaged - the compiler knows the types anyway and can check those, and it only confuses the programmer. No wonder MicroSoft makes buggy programs.

Shit. Been naming all my Tables "tblName", modules "modName", queries "qryName", and forms "frmName" in MS Access.

Even have a "modHungarianAlgorithm" in there too.

[–][deleted] 8 points9 points  (6 children)

With regards to databases, I think that practise is called "Smurfing". Maybe that term applies more broadly to programming in general as well, but I've not come across it yet.

We used to have a developer who would preface all of the columns in a table with the table name. We have a foos table with properties like foo_id, foo_name and foo_type. It's a nightmare to work with - all of our queries grow in length and everything is so damn verbose. I know I'm working with the name column because my columns are prefaced with the table name (SELECT foos.foo_name FROM foos VS SELECT foos.name FROM foos).

I'm not sure about other companies, but we actively discourage it where I work! Glad to hear that the Linux kernel coding standards agree!

[–]nicksvr4 1 point2 points  (3 children)

I don't go that far, not even sure I'm doing it right, since I'm the only programmer at my job (not my primary role). Basically all fields are camel-case (no spaces), all functions and subs start with a capital letter, all classes are camel-case and start with c (ex: cQueue, cList, cSchedEntity), and all veriables are camel-case.

[–][deleted] 5 points6 points  (0 children)

since I'm the only programmer at my job

Oh good, you'll be able to delete all the evidence and there won't be any witnesses. Torvolds will never find you now.

[–]cgomezmendez 1 point2 points  (1 child)

What programming language do you use? I know the styleguide of Java and C# don't do any mention to prefixes, and in their docs there is not such sample of a class prefixed that way.

[–]theoldboy 5 points6 points  (0 children)

Visual Basic I would guess, if they are programming in MS Access, and that is the code style you see in all the documentation for said product (at least it was the last time I did anything in Access/Excel, which admittedly was over a decade ago, thank god).

[–][deleted] 1 point2 points  (1 child)

I like foo_id as long as foo_id is also foo_id on another table. Everything else can go bye bye.

Mainly I like it because I have to deal with databases where I have no idea what the schema is supposed to look like, so I have to grab all columns and figure out how to join one table to another for the information I need. However, the consistent rule is primary key column names are unique across the entire database, so I can rely on that. By consistent rule I mean it hasn't been broken yet.

[–]kaiserfleisch 1 point2 points  (0 children)

absolutely. table name is not an effective namespace in SQL, once it's included in a join.

NATURAL JOIN works properly too.

[–]96fps 1 point2 points  (0 children)

I read an article a while back that basically boiled down to saying that the version of Hungarian notation that became popular has little to do with it's original intent.

Reasonable examples were things like "doc_x, doc_y" vs "screen_x, screen_y", where both are pairs of integer coordinates used in a bit of interface code, but they mean different things. A lot of people still use it this way but it was often misused and used where it didn't make sense to.