7 ms·
Ask HN: What horrible things do you do in your own code when no one is watching?
It's your code, no one else will ever see it or maintain it. What worst practices and cheap shortcuts do you use when you really are going "quick and dirty?"
- dundercoder 9y agoGlobal variables... I'm ashamed.
- dhotson 9y agoSingle letter variable names.
- dundercoder 9y agoand reuse of them!
- donald544 9y agooh, I too like to live dangerously!
- orochi235 9y agoNo tests. At all. Ever.
- matchmike1313 9y agoSkipping tests...
- jszersze 9y agoStory of my life, unless someone is paying for it.
- mod 9y agoI do all of these things in the same block of code. Somebody off me.
- fiokoden 9y agoPremature optimization. Cause it's fun.
- dundercoder 9y agoI have a severe case of this. So few personal projects even get started because I get caught up in scalability and what not.
- hacking_again 9y agoHard code passwords and temporary filenames.
- mattbillenstein 9y agoDitch optparse or argparse -- "flag = '--flag' in sys.argv" or "if len(sys.argv) > 1: arg = sys.argv[1]" will usually do...
- ezekg 9y agoNice. Haha I use a switch statement: process.argv.forEach((arg, i, argv) => { switch (arg) { case "--foo": foo = argv[i + 1] break case "--bar": bar = argv[i + 1] break } })
- emilburzo 9y agoSkipping the getter/setter dance for POJOs and just using public fields.
- AlexAmee 9y agoYou at least made them final right ?
- daedalus13 9y agoProfanity. It can look like a key party got out of hand in there. Use g for a string variable at least once.
- hanniabu 9y agoWhat's the significance of using 'g' as a variable name?
- acukan 9y agoNot just variable name a "string" variable name, See g string ^^
- PaulHoule 9y agoI got bitched out by a boss once for using the number 666 in a unit test.
- cpx86 9y agoI can never resist naming Assembly variables ass. Also leads to lots of fun variations: dynamicAss, assBuilder, assTypes, ...
- muzani 9y agoMinimal comments and documentation. Why should I comment or document if no one else will ever see it maintain it?
- bananicorn 9y agoI'm guilty of the exact opposite - sometimes I comment too much, to the point that the code becomes LESS readable... or a huge block of comments at the head of my main file, with all the TODOs... Also, not using version control, and only switching to it when the project is already a considerable size...
- balazsdavid987 9y agoDebugging by writing variables and intermediate steps to the console.
- fiokoden 9y agoI'll write tests when the product makes money.
- soulchild37 9y agoAt least write test on payment stuff, I learned the hard way by screwing up payment system when user emailed me why he can't go through payment.
- PaulHoule 9y agoIt really amazes me how many companies (especially the ones with an avaricious reputation such as health insurance companies) don't take the payment system seriously.
- deleted 9y ago[deleted]
- deleted 9y ago[deleted]
- mtmail 9y agoPerl one-liners in bash scripts. The kind that don't use spaces or bracket. Of course one-character variable names and use of special variables like $\, $| or $& (http://perldoc.perl.org/perlvar.html http://perldoc.perl.org/perlvar.html). Execute code withing regular expressions. Almost obfuscation. I assume they break whenever a new minor version of Perl is released.
- rthomas6 9y agoLike 3 nested listcomps on one line (Python).
- ezekg 9y agoWriting an entire app in a single file that ends up being a few thousand lines of code. It started as a few hundred, but grew from there (like always), and now there's no turning back until it's launched and validated! No use wasting time refactoring until I know it'll work.
- patrics123 9y agoWriting extensive TODO comments for future features instead of actually implementing them. Never read a single ToDo comment afterwards. Ever.
- AlexAmee 9y agoint x; String str;
- krapp 9y agoOh dear. I've done just about everything on this page... I never hide data. All structs with all public members. Even if I write an API around that, I can still just access everything directly if I want to. When I use raw pointers, I usually don't check for nullptr. I abuse unions and their initial members and don't bother checking tags even if I tag them. Does it compile? Good. Does it run? Good. If I leave it running does it eat all my RAM? No? it's probably fine then. I tend not to push changes for weeks or sometimes months, and my commit message is basically that I forgot everything I actually changed. Also, my commit messages are terrible. I keep one big text file full of notes, comments and old code pasted in. My source code itself tends not to be commented well as a result.
- rl3 9y agoProper async code tends to go out the window where timers will suffice. It's filthy, but often faster and it works for whatever narrow problem the one-off script in question is solving.
- slimshady94 9y agoThe ever-present possibilty of open-sourcing on github and getting code-reviewed by future employers hangs over my head like the sword of Damocles.
- krapp 9y agoThat's one of the reasons I no longer use Github. I don't want every line of code I write to be used as part of a hiring filter, much less just the languages I'm tagged with or the number of stars in my repos or in anything I contribute to. The more useless social media BS Github piles onto its site the more it becomes the new Linkedin... no thanks.
- frou_dh 9y agoThat sounds a bit like fretting over the fine details of which clothes to wear. There's a good chance the other party is not that interested, and does not dwell on or even notice these things.
- NumberCruncher 9y agoAll throw away db table names starts with suxx_.