|
Subjunctive posted:Yes, this lets the compiler catch typos. Also makes internationialization easier.
|
# ? Aug 9, 2015 02:40 |
|
|
# ? May 26, 2024 23:21 |
|
LeftistMuslimObama posted:Also makes internationialization easier.
|
# ? Aug 9, 2015 04:11 |
|
If you're actually dealing with different currencies then you're probably going to do more than just some simple text replacement, since USD is semantically different than GBP.
|
# ? Aug 9, 2015 04:24 |
|
Subjunctive posted:Yes, this lets the compiler catch typos. This was actually being done in a type of environment where the typo would have been caught since the compiler (interpreter in this case) would know to check against a predefined set of currency codes so either the compilation or the very first run of the program would have caught the issue. LeftistMuslimObama posted:Also makes internationialization easier. USD (and similar codes) are driven by an ISO standard so internationalization wouldn't be a concern in that case.
|
# ? Aug 9, 2015 04:31 |
|
TheBlackVegetable posted:I think this is a good first step towards pulling that magic number out of the code and into config. Nah, this is the only place it's used in the whole program. It's an environment for Reinforcement Learning with an Atari Emulator and this was from the Space Invaders glue. The class file itself is basically the "config file" for all the RL stuff related to the Space Invaders ROM.
|
# ? Aug 9, 2015 04:31 |
|
Some variable names replaced (this is Java).code:
|
# ? Aug 11, 2015 08:25 |
|
My favourite part is where it returns null instead of an empty array.
|
# ? Aug 11, 2015 09:02 |
|
Well then you'll like this: https://github.com/KeenSoftwareHouse/SpaceEngineers/blob/master/Sources/Sandbox.Game/Game/GUI/MyGuiBlueprintBase.cs Line 274code:
In a not totally unrelated note, Space Engineers made their source code available on Github.
|
# ? Aug 11, 2015 12:09 |
|
NihilCredo posted:My favourite part is where it returns null instead of an empty array.
|
# ? Aug 11, 2015 14:53 |
|
On a project I worked on this guy wrote a "get XML value as Boolean" function that returned null when it didnt exist. I hated that function.
|
# ? Aug 11, 2015 15:06 |
|
I've got a JobManager object that shouldn't really exist when there isn't a job running, but I don't like nulls so I created an UninitializedJobManager that just executed nops or returned stuff like "IllegalStateException("Job manager is not initialized")" to things like status queries - I documented all of this, assuming that anybody running status queries would just log any exceptions and move on if they got an exception (or, worst case, they'd get something like a 404). One of my co-workers wrote a status monitor that promptly crashed the program when it encountered the IllegalStateException. And he didn't just say "hey can you replace that exception with a string" or whatever, instead he said "AHHHHH THE PROGRAM IS CRASHING." The same co-worker accidentally (I hope) deleted all of my code a few days ago - he was merging my code onto master, but he used the version of my code that existed four months ago (I have no idea where he even found a branch that old).
|
# ? Aug 11, 2015 15:49 |
|
tyrelhill posted:On a project I worked on this guy wrote a "get XML value as Boolean" function that returned null when it didnt exist. I hated that function. Edit: That also reminds me of a Ruby horror, related to the ES stuff - symbols versus strings. Which will a gem return? Who knows! Gotta read the code, and hope they don't change the contract on version bumps (spoiler: they do). And garbage like that introduces classes like HashWithIndifferentAccess. Less Fat Luke fucked around with this message at 18:04 on Aug 11, 2015 |
# ? Aug 11, 2015 17:59 |
|
Less Fat Luke posted:Edit: That also reminds me of a Ruby horror, related to the ES stuff - symbols versus strings. Which will a gem return? Who knows! Gotta read the code, and hope they don't change the contract on version bumps (spoiler: they do). And garbage like that introduces classes like HashWithIndifferentAccess. One of the most terrible parts of ruby, for sure.
|
# ? Aug 12, 2015 09:01 |
|
Tank Boy Ken posted:Well then you'll like this: https://github.com/KeenSoftwareHouse/SpaceEngineers/blob/master/Sources/Sandbox.Game/Game/GUI/MyGuiBlueprintBase.cs Line 274 This is actually the code I was referring to when I brought up the "my" prefix thing. I tried making mods for it one day, but it's such a trainwreck. code:
dougdrums fucked around with this message at 15:02 on Aug 12, 2015 |
# ? Aug 12, 2015 14:56 |
|
Yeah as beginning hobby coder this is something you see people use in a lot of tutorials to explain things. Which is bad since it wouldn't hurt to start off with "good" naming conventions. Though I personally do use "my....." too. Usually in constructors:code:
|
# ? Aug 12, 2015 15:22 |
|
Is "my" just a vestige of perl's silly way of declaring local variables or was it around before that?
|
# ? Aug 12, 2015 15:59 |
|
I've never touched perl and I've seen it in a lot of Java code You've created, I dunno, a Queue, but there's already a Queue. What distinguishes your Queue from the existing Queue that you can use to give it a good name? gently caress that, call it MyQueue I ran into one guy who made JohnQueue, JohnArray, etc. In a lot of cases there was already a MyQueue and MyArray, so he took it a step further.
|
# ? Aug 12, 2015 16:13 |
|
I've seen it in some books on "How to learn to code in XXX". Most of the time in abstract simple and short code examples. And the msdn also loves it (C#): https://msdn.microsoft.com/de-de/library/w5zay9db%28v=VS.120%29.aspxcode:
|
# ? Aug 12, 2015 16:25 |
|
KernelSlanders posted:Is "my" just a vestige of perl's silly way of declaring local variables or was it around before that? I always thought it was a vestige of tutorials that were trying to reinforce the difference between an instance of a class and the class itself.
|
# ? Aug 12, 2015 17:25 |
|
I remembered this too: https://msdn.microsoft.com/en-us/library/20fy88e0.aspx (Me, My, MyBase, and MyClass in Visual Basic)loinburger posted:I ran into one guy who made JohnQueue, JohnArray, etc. In a lot of cases there was already a MyQueue and MyArray, so he took it a step further. I name some of my libraries like this, like dougmem.h but with my last name. dougdrums fucked around with this message at 17:34 on Aug 12, 2015 |
# ? Aug 12, 2015 17:31 |
|
Common in Python tutorials too to teach you to avoid overwriting the lowercase builtin names like dict and list.
|
# ? Aug 12, 2015 18:04 |
|
I once shipped some code that connected to a postgres database through a handle named mySQL.
|
# ? Aug 12, 2015 22:40 |
|
I worked for a Swedish company that used a mixture of Swedish and English (often in the same variable/class name), which was confusing as hell until I got the hang of it. The worst example was "minHeap", which was actually a max heap, were "min" means "my." I'm pretty sure that was done just to gently caress with the American programmers.
|
# ? Aug 12, 2015 22:58 |
|
ShoulderDaemon posted:I once shipped some code you monster
|
# ? Aug 12, 2015 23:08 |
|
ShoulderDaemon posted:I once shipped some code that connected to a postgres database through a handle named mySQL. I assume Oracle was involved somewhere.
|
# ? Aug 13, 2015 01:26 |
|
ShoulderDaemon posted:I once shipped some code that connected to a postgres database through a handle named mySQL. Shoulda been called myMySQL.
|
# ? Aug 13, 2015 03:09 |
|
loinburger posted:I worked for a Swedish company that used a mixture of Swedish and English (often in the same variable/class name), which was confusing as hell until I got the hang of it. The worst example was "minHeap", which was actually a max heap, were "min" means "my." I'm pretty sure that was done just to gently caress with the American programmers. In my company all the programmers are Brazilian. Until we started one of the latest projects, all the class names and variable names were in English, as the style guide dictated. Nowadays, it's a horrible mismatch between Portuguese and English without any rhyme or reason to it.
|
# ? Aug 13, 2015 03:31 |
|
dougdrums posted:I remembered this too: https://msdn.microsoft.com/en-us/library/20fy88e0.aspx (Me, My, MyBase, and MyClass in Visual Basic) I had to maintain several huge pieces of code full of variables named ABCflag1, ABCnum3, ABCpic5 where ABC are the initials of the guy who created the software years before that. Then I enjoyed trying to understand what the gently caress code like this does: code:
That guy is now an uberboss in the company.
|
# ? Aug 13, 2015 08:51 |
|
loinburger posted:I worked for a Swedish company that used a mixture of Swedish and English (often in the same variable/class name), which was confusing as hell until I got the hang of it. The worst example was "minHeap", which was actually a max heap, were "min" means "my." I'm pretty sure that was done just to gently caress with the American programmers. That's great. I've run into code where the variable $noRetries apparently meant "number of retries" rather than, as I originally read it, "disable retries", but yours is better.
|
# ? Aug 13, 2015 10:29 |
|
I got really excited to write a line of PHP code that looked for misspellings of "pregnant" (pregnet, pregant, pregnent, etc.) using preg_match()
|
# ? Aug 13, 2015 19:12 |
how is T_PAAMAYIM_NEKUDOTAYIM formed. how girl get preg_match()
|
|
# ? Aug 13, 2015 22:31 |
|
The Something Awful Forums > Discussion > Serious Hardware / Software Crap > The Cavern of COBOL > Coding horrors: how is T_PAAMAYIM_NEKUDOTAYIM formed. how girl get preg_match()
|
# ? Aug 13, 2015 22:37 |
|
Sinestro posted:The Something Awful Forums > Discussion > Serious Hardware / Software Crap > The Cavern of COBOL > Coding horrors: how is T_PAAMAYIM_NEKUDOTAYIM formed. how girl get preg_match() not emptyquoting.
|
# ? Aug 13, 2015 23:31 |
|
More of a security horror but still http://www.theregister.co.uk/2015/08/12/lenovo_firmware_nasty/ :lolnovo:
|
# ? Aug 14, 2015 00:44 |
|
Those are some brazen fuckers right there.
|
# ? Aug 14, 2015 03:03 |
|
Well, that's basically what WPBT is designed to do. It's a pretty stupid feature that's just waiting for all kinds of hilarious exploits when someone finds a way to write to it from the OS.
|
# ? Aug 14, 2015 03:18 |
|
Subjunctive posted:Those are some brazen fuckers right there. Superfish 2: Electric Boogaloo "Seriously what if we just stopped giving a gently caress?"
|
# ? Aug 14, 2015 03:45 |
|
Oh yeah, so the Android StageFright patch didn't really work because integers are hard and untyped macros are bad.
|
# ? Aug 14, 2015 04:04 |
|
Sinestro posted:The Something Awful Forums > Discussion > Serious Hardware / Software Crap > The Cavern of COBOL > Coding horrors: how is T_PAAMAYIM_NEKUDOTAYIM formed. how girl get preg_match() it was on haker news this mroing
|
# ? Aug 14, 2015 04:05 |
|
|
# ? May 26, 2024 23:21 |
|
ultramiraculous posted:Superfish 2: Electric Boogaloo I'm having lunch with some other Superfish-excitement people next week and I think it's going to be like Requiem for a Dream.
|
# ? Aug 14, 2015 04:50 |