Re:Crazy, Heretical, and Awesome: The Way I Write Rails Apps
by perlgeek on Tuesday August 02, 2011 @10:17AM
(#2837172)
Is it somehow hip to misspell "class" as "klass", or is there a deeper meaning behind it?
[ Parent
| on HN ]
Re:Crazy, Heretical, and Awesome: The Way I Write Rails Apps
by raganwald on Tuesday August 02, 2011 @12:32PM
(#2837703)
It is a sound engineering practice to avoid using keywords as names even when the language’s parser will let you get away with it. For consistency, some developers (myself included) will avoid words like `class` and `module` even when embedded in a longer name, such as `user_class`.
I don’t use `klass`, but that’s because I’m a Java Bigco cubicle-dweller fraudulently passing himself off as a Rubyist and Javascripter. I prefer `clazz` in keeping with Sun examples.
Re:Crazy, Heretical, and Awesome: The Way I Write Rails Apps
by DanielStraight on Tuesday August 02, 2011 @10:18AM
(#2837175)
class is a keyword.
Re:Crazy, Heretical, and Awesome: The Way I Write Rails Apps
by arctangent on Tuesday August 02, 2011 @10:27AM
(#2837224)
The word doesn't seem to be used by itself however - the code in the article contains "user_klass" and "log_klass", which can presumably be spelled correctly without causing an issue?
Re:Crazy, Heretical, and Awesome: The Way I Write Rails Apps
by pak on Tuesday August 02, 2011 @10:49AM
(#2837301)
Yeah, it can, but perhaps you develop a habit for it whenever creating variable names, so there is some visual harmony between klass, old_klass, klass_dismissed, etc. when reading the code.
Re:Crazy, Heretical, and Awesome: The Way I Write Rails Apps
by damoncali on Tuesday August 02, 2011 @12:05PM
(#2837601)
The k is a useful visual hint, even when not necessary.
Re:Crazy, Heretical, and Awesome: The Way I Write Rails Apps
by stefan1 on Tuesday August 02, 2011 @10:19AM
(#2837184)
I think perlgeek was referring to the use of user_klass and log_klass.
Re:Crazy, Heretical, and Awesome: The Way I Write Rails Apps
by sugerman on Tuesday August 02, 2011 @10:20AM
(#2837188)
Not in the way its used in his samples.
Re:Crazy, Heretical, and Awesome: The Way I Write Rails Apps
by oinksoft on Tuesday August 02, 2011 @11:08AM
(#2837374)
I use `cls` in my ruby code, as I do in other langs; I think `klass` is unsightly.
Re:Crazy, Heretical, and Awesome: The Way I Write Rails Apps
by ojilles on Tuesday August 02, 2011 @12:14PM
(#2837638)
... to a non-German?
Re:Crazy, Heretical, and Awesome: The Way I Write Rails Apps
by pilif on Wednesday August 03, 2011 @03:40AM
(#2840193)
... even to a German. It's Klasse, not "klass" (the ending e and the capital K are of some importance here)
Re:Crazy, Heretical, and Awesome: The Way I Write Rails Apps
by ojilles on Wednesday August 03, 2011 @09:21AM
(#2841012)
Ah, correct, thanks :-)
Re:Crazy, Heretical, and Awesome: The Way I Write Rails Apps
by lightyrs on Tuesday August 02, 2011 @11:51AM
(#2837554)
klass is used in meta programming as a way to control scope.
Re:Crazy, Heretical, and Awesome: The Way I Write Rails Apps
by kyledr on Tuesday August 02, 2011 @11:36AM
(#2837489)
The author of the code must like German. He used "Matz" as a parameter, a German name, and klass = class in German.
Re:Crazy, Heretical, and Awesome: The Way I Write Rails Apps
by mnutt on Tuesday August 02, 2011 @11:42AM
(#2837512)
Matz is short for Yukihiro Matsumoto, the creator of Ruby.
Re:Crazy, Heretical, and Awesome: The Way I Write Rails Apps
by eis on Tuesday August 02, 2011 @01:42PM
(#2837974)
Matz is neither a common german name (I've never encountered it) nor is class "klass" in german. It's "Klasse".
Maybe you just missed out an "e" on the name aswell? There is "Matze" which would be a short version of "Mathias".