|
Variable names should balance clarity and brevity. num_apples is a perfect variable name while n (too short), number_of_apples (too long), and apples (too ambiguous) aren't very good names for the same variable. result is useful in some places. For example if you are checking the return value/error code of many functions it's useful to have a single variable to do it in rather than cluttering the sub with a ton of one-off variables.
|
# ¿ Mar 29, 2008 18:41 |
|
|
# ¿ Apr 29, 2024 21:43 |
|
Can't you just put the breakpoint on the closing brace?
|
# ¿ Jul 8, 2008 22:13 |
|
zootm posted:In most languages you can't breakpoint on a line that isn't executed; braces are just syntax.
|
# ¿ Jul 8, 2008 23:14 |
|
JoeNotCharles posted:What's wrong with this? The only weird thing I can see is that db.Open is called after creating the transaction, but that doesn't have anything to do with your comment so I assume that's just the way the API works.
|
# ¿ Jul 10, 2008 16:34 |
|
I came across the original version of the Ken's Labyrinth source code by Ken Silverman of BUILD engine fame (which powered Duke3D) here. It's 8000 LOC in one single C file. It's pasted here for the time being: http://rafb.net/p/mrXyPD73.html
|
# ¿ Jul 26, 2008 18:08 |
|
Munkeymon posted:I was thinking a shorthand just for this case: code:
|
# ¿ Aug 27, 2008 16:59 |
|
I don't consider it monkeypatching because the extension method does not have any access to internal members of the class or indeed any special privileges that do not exist when the method is implemented normally. The extension method has to be in scope (i.e. imported) in order to use it, and I believe it is translated into a traditional function call in the IL. Obviously, it should be used sparingly and be documented well when it is, but it's how things like LINQ are implemented, and it's a real blessing.
|
# ¿ Aug 27, 2008 18:38 |
|
No, because if the number of possibilities is small enough that you would otherwise list them in the code then the performance difference is negligible. If the choices are dynamic or enormous you'll probably (hopefully) be using a list operation anyway (albeit not likely an inline one). Only if you are doing many such checks in rapid succession would the difference manifest itself, in which case you would then optimize accordingly. Of course, you shouldn't be optimizing before you need to anyway. So any drawbacks are in most cases purely theoretical.
|
# ¿ Aug 27, 2008 21:50 |
|
The fact that you are printf'ing a string stored in a variable and not a literal means that the value could change in the future without even looking at or knowing about the existence of the printf in question. If it changes to a string which contains a %, it introduces undefined behaviour that could have easily been prevented. It even specifically states this in K&R (page 155). On the other hand, there's no point in doing it in the python code since there's no vulnerability to start with.
|
# ¿ May 4, 2009 23:22 |
|
I can't see the code but it's definitely a coding horror. http://forums.somethingawful.com/showthread.php?threadid=3161210 I just sniffed the packets for this game out of curiosity and it sends raw SQL commands back and forth between client and server, as well as updating the SQL backend every 1 second or so for a heartbeat keepalive type thing.
|
# ¿ Jul 2, 2009 07:11 |
|
Why wouldn't you just specify a particular shade of dark green in the first place if you cared that much
|
# ¿ Aug 28, 2010 19:45 |
|
That looks like generated code to me.
|
# ¿ Apr 9, 2011 07:55 |
|
Aleksei Vasiliev posted:https://code.google.com/p/java-compress/source/browse/src/org/jvcompress/lzo/MiniLZO.java#137 That doesn't mean it isn't generated, I write code generating scripts all the time.
|
# ¿ Apr 9, 2011 08:24 |
|
yaoi prophet posted:Huh, this looks interesting. Any idea why the mentioned languages don't use his approach?
|
# ¿ Apr 13, 2011 20:04 |
|
1337JiveTurkey posted:You have to explicitly tell the standard Java regex to backtrack with (.*?) because it can significantly affect performance.
|
# ¿ Apr 13, 2011 20:17 |
|
tef posted:perl regexes are pretty much turing complete, not just context-free
|
# ¿ Apr 14, 2011 02:42 |
|
Is there some kind of quine theory that reduces creating quines to some sort of mechanical procedure, or did that guy just spend way too much time on it
|
# ¿ Apr 17, 2011 00:20 |
|
I think maybe that IBM JSON thing is because whatever that web service is, it works with XML internally, but can interoperate with JSON externally. So clients can send JSON to it and it will work transparently. At least that's the impression I got. It's ugly, but interop usually is.
|
# ¿ Apr 30, 2011 06:55 |
|
schnarf posted:All hail my terrible C++ template metaprogramming FizzBuzz: http://codepad.org/MCDF6Zt9. There's no runtime branching.
|
# ¿ May 23, 2011 00:37 |
|
yaoi prophet posted:An anonymous person sends a type-level Fizzbuzz complete with an example run. Mine is better. You have to compile it with -fcontext-stack=105 for it to work. Yes, I am a monster. code:
Volte fucked around with this message at 10:52 on May 27, 2011 |
# ¿ May 27, 2011 10:25 |
|
qntm posted:I thought I was the only one who did this! code:
|
# ¿ Aug 1, 2011 01:55 |
|
If you ever come to a point where you think "A goto would be really easy here, otherwise I'll have to add in a bunch of boolean flags and conditionals to code my way around it" and then add in the boolean flags and conditionals, you're doing it wrong
|
# ¿ Sep 8, 2011 00:08 |
|
Factor Mystic posted:Welp.
|
# ¿ Dec 24, 2011 03:46 |
|
OCaml uses the semicolon for the same purpose, but it does not do anything weird with returning unit. code:
|
# ¿ Jan 31, 2012 10:08 |
|
w00tz0r posted:"So each node has either a branch or a leaf..."
|
# ¿ Feb 7, 2012 04:00 |
|
I think Branch and Leaf are supposed to inherit from Node or something. Either that or it's an incomplete paste and Branch is what contains the pointer to the subtree. Still really dumb though
|
# ¿ Feb 7, 2012 06:11 |
|
Instead of thinking of the braces as belonging to the if statement, think of them as denoting a single compound statement (because that's what they do, in the grammar). A branch of an if-statement always contains a single statement, but that single statement may be a compound statement. It's not that hard to get used to verifying that the statement after an 'if' is of the correct form. On the other hand, if the code style that you have to follow specifies that you need to use single-statement blocks, then that trumps all the other reasons you can think of for not doing it.
|
# ¿ Mar 25, 2012 01:42 |
|
What kind of a noob language are you using that has assignment?
|
# ¿ Sep 2, 2012 15:55 |
|
yaoi prophet posted:I bet you thought you'd seen all the weird coding styles people use. Well, I bet you've never seen semicolons at the start of lines.
|
# ¿ Oct 8, 2012 04:28 |
|
Zombywuf posted:You know that the letters on the top of the keys aren't anything to do with the characters on the screen right?
|
# ¿ Nov 18, 2012 22:22 |
|
Cocoa Crispies posted:If your functions are taller than about ten (twenty is pushing it) lines that's the problem.
|
# ¿ Nov 23, 2012 16:02 |
|
If you take one-time-only code and turn it into a nullary function, all you're doing is making it hard to follow for no reason. Just put a comment for gently caress sakes.
|
# ¿ Nov 23, 2012 19:02 |
|
There's no need to refactor Q_rsqrt at all. The only things missing are comments that actually explain how it works. "Self-documenting code" doesn't mean that your code should literally have the explanations of how it works in the names of the variables and functions.
|
# ¿ Nov 23, 2012 22:41 |
|
Zombywuf posted:When I see a codebase full of 3000 line functions my preferred blanket rule is "Don't do that or I'll break your fingers." Good style doesn't fix bad code, but bad style makes it worse.
|
# ¿ Nov 26, 2012 02:48 |
|
Catching all exceptions in Main is fine for production releases, since in the event of a fatal error you can display a pretty error message with an appropriate amount of information rather than whatever normally happens (like a generic .NET exception message followed by an illegal operation), plus you can generate an error report that can be sent in. Catching all exceptions anywhere other than Main is really dumb though.
|
# ¿ Dec 2, 2012 12:40 |
|
Also, if you're rethrowing the exception then you're effectively not catching it at all, from a control flow point of view. You're just temporarily intercepting it and doing some debugging side effects.
|
# ¿ Dec 2, 2012 16:12 |
|
Zhentar posted:Nope, this is still wrong. .NET offers several events (such as AppDoman.UnhandledException) that you can (and should) hook to achieve this, without writing a try/catch at all.
|
# ¿ Dec 2, 2012 20:29 |
|
Zhentar posted:You are, in fact, wrong. I've used them to replace the standard .NET popup with automatic error reporting.
|
# ¿ Dec 3, 2012 11:12 |
|
Star War Sex Parrot posted:People are allowed to not like YOSPOS, but in my experience it just means that you take yourself too seriously. edit: my mental picture of YOSPOS posters is slightly chubby teens wearing cardigans and shades while sneering
|
# ¿ Dec 5, 2012 22:40 |
|
|
# ¿ Apr 29, 2024 21:43 |
|
Golbez posted:How much is Hungarian notation despised here? I had to adopt it due to my predecessor and I've kept using it, though not in objects (it seems weird to get $oObject->sName instead of $oObject->Name), and as we move towards an OO framework in PHP I suspect that will drop off each more. It does give me a nice built in temp variable name though - $s for strings, $b for booleans, $a for arrays, etc. $i is for integers but that's one thing that's already in common use, in for loops at least.
|
# ¿ Dec 5, 2012 23:46 |