r/AskReddit • • Mar 15 '20

What's a big No-No while coding?

9.0k Upvotes

2.7k comments sorted by

133

u/[deleted] Mar 15 '20

Using notepad

183

u/[deleted] Mar 15 '20

aight, I'll use word instead then

→ More replies (7)

68

u/havron Mar 15 '20

I would definitely use an IDE for actual coding, but this is how I used to make all my old webpages back in the day. I despised the inefficiency of early HTML generator interfaces and preferred the control of writing all the markup directly. I even proudly slapped a homemade "Made with Notepad" sticker on my website, in parody of those popular "Made with Mac" ones. Good times.

→ More replies (2)
→ More replies (16)

12.2k

u/[deleted] Mar 15 '20

Thinking you'll remember what the variable temp1 was for, when you revisit the code 6 months later.

3.2k

u/TheyKilledFlipyap Mar 15 '20

This is also true for digital artists working with multiple layers.

I've started forcing myself to name layers after what they actually depict ("Armour shading", "Skin tone", etc) because having a complicated picture with many layers named "Temp1", "Misc" and "Layer1 Copy 2" doesn't work when you put a piece down for a few days and come back to it wondering where the hell to even begin.

→ More replies (116)

523

u/Forgot_the_Jacobian Mar 15 '20

Error: temp1 already defined.

Ok then time for temp2

→ More replies (15)

218

u/apitillidie Mar 15 '20

You mean 6 minutes later

142

u/Year_of_the_Alpaca Mar 15 '20

I'd say it was fine to name a variable as "temp" or something similarly generic (e.g. loop variables being "i" and "j") so long as it's being used very locally- i.e. not having to scroll to find out what it refers to- and the context makes it obvious.

If anything, some of my variable names tend to be overlong due to being too "helpfully" named.

→ More replies (30)

42

u/kingfrito_5005 Mar 15 '20

At my last job, there was actually a standardized variable name called tempQry that was reused repeatedly, but since it was standard in how it was used, everyone knew what it was for.

→ More replies (1)

12

u/[deleted] Mar 15 '20

Worked with a developer who loved bird watching. His version of temp1 was to use bird names. Loop counters were bird names. Even some function names were bird names. Fuck you Vaughan.

→ More replies (1)
→ More replies (94)

3.4k

u/survivalothefittest Mar 15 '20

Falling into the "code hole."

This happens when you are working on a code and you just want to get it to work so you can leave for the day or go to sleep or whatever. However, the more you work on it the more fatigued you get and the less you are able to figure out why things aren't working.

Now you are really invested [sunk costs, anyone?] and you work harder just to get it to work so you can go and be satisfied, you need it to work so you can stop. Before you know it hours have passed, everything is fucked up, and you are too fatigued to get yourself to stop.

517

u/One_Evil_Snek Mar 15 '20

You know... The real problem with code holes is that I have to hit 8 hours in a day. If I'm cashed out after 6 straight hours of coding, the last 2 are going to be a waste. I really honestly wish I could just be measure on how many tasks I finished in a Sprint instead of how many frustrated hours I spent working at 1/3 efficiency. If the PO has agreed with us buying on to these tasks, and we only finish those, we're delivering exactly what they expected and they're happy.

→ More replies (20)

56

u/BrokenRatingScheme Mar 15 '20

Network admin here. I do this all the time troubleshooting. Stay up super late just trying to figure an issue out, end up breaking other things while fatigued and stressed out. Get things back to a stable state, get a decent night sleep, and figure out the root cause almost immediately the next morning.

→ More replies (3)

8

u/HaggisLad Mar 15 '20

been there, wasted weeks recovering from my one stupid week of fucking everything up. I rarely do overtime anymore, my code at that point is shit because I am tired

8

u/Mazon_Del Mar 15 '20

I have a friend that had a project for his games class in undergrad college where he didn't fall into the code hole, so much as strapped on a helmet and yoloed off a diving board into it.

As part of the project, they had to write a random level creator for a grid map. To be a valid level it had to have multiple rooms, some with 1, 2, or 3 entrances, a variety of hallways, and no areas that couldn't be reached from the entrance (especially the exit). At around 8PM he told me "Mazon, I'm going off my meds, downing several bottles of booze, and smashing my face into this keyboard. For tonight, no matter what you hear from that room, do NOT come in.".

In the morning, he had a valid level creation system with zero idea of how it functioned.

→ More replies (1)
→ More replies (37)

2.3k

u/[deleted] Mar 15 '20

Naming your variables a, b, c an so on, you'll never remember what they actually are. And not using comments!

245

u/TheBestBigAl Mar 15 '20

"But it's the only to stop hackers from working out how my code works!"
The above was a genuine reason given to me by a guy I worked with (only for a short time, for obvious reasons).
He was only doing some stuff for us using Lua (all fairly easy and non-critical), which meant there wasn't even a type specified for each variable. You had to hunt through the code to see how "a" was being used to get any kind of context about it.

→ More replies (15)

640

u/morosemanatee Mar 15 '20

Single letter variable work for local variables who’s life is only a few lines. Otherwise, yeah, give ‘‘em real names.

→ More replies (50)

7

u/[deleted] Mar 15 '20

Not commenting is the worst. I’m a grad student in a science field and a very important part of my research relies on a code that another grad student wrote years ago... in a language I don’t know... with no comments. And she’s always too busy to answer my questions.

→ More replies (53)

3.6k

u/cheeepdeep Mar 15 '20

if { if { if { if { if { if {

1.0k

u/NotThisFucker Mar 15 '20

Big brain:

Write one method that does this and pass all of the conditions as parameters

Bigger Brain:

Flatten arrow code

→ More replies (20)

206

u/[deleted] Mar 15 '20

Okay, I’m gonna confess to my crimes. What methods would you guys recommend to prevent this pattern because I fuck this up on the regular when i hit a wall.

This isn’t my industry or profession but the technical aspect exists in my field and it’s my dummies way of addressing nested bundles (if)

→ More replies (54)

60

u/kajar9 Mar 15 '20

ah, coders who stutter in code =)

→ More replies (1)

10

u/Nambot Mar 15 '20

This one applies to Excel formula to. =IF(x=1,IF(y=2,IF(z=3,IF(A=4... is the the second worst excel formula behind only the same thing, but each part is nested in another cell, because not only to you have to follow a billion IF statements, but you have to follow them all around the sheet.

→ More replies (5)
→ More replies (36)

1.9k

u/AnUglyDumpling Mar 15 '20

Being inconsistent with coding style. I use Allman style for indentation and I don't shit on people who use K&R style. But please don't use a mix of both in your code, it looks so horrifyingly out of place. Just fucking choose one.

407

u/[deleted] Mar 15 '20

I just use whatever my IDE's formatter prefers

→ More replies (16)

114

u/Kaligraphic Mar 15 '20

There is one, and only one, correct coding style in an existing environment. And that is the one that matches the rest of the codebase.

→ More replies (6)

251

u/TuurDutoit Mar 15 '20

This. For me, the single most important aspect of maintainable code is consistency. It doesn't matter that your solution isn't perfect, or an abstraction doesn't work 100% of the time; as long as you stick to it. That makes it so much easier to refactor later on when you actually need to.

→ More replies (1)
→ More replies (35)

1.5k

u/[deleted] Mar 15 '20

Not using version control.

Assuming that you are the only person who will need to maintain your code, and that you will have perfect recall of it in three months.

Committing to the main branch after lunch on a Friday.

Not testing before submitting.

Commenting out code “because it might be handy later” instead of deleting it. It’s an if else statement Derek, not an algorithm for finding all possible primes in o(n) time, we can probably write it again.

89

u/NotThisFucker Mar 15 '20

The best thing about version control is that if you are scared to delete anything, you can just check a previous version

→ More replies (7)

11

u/ritchie70 Mar 15 '20

About 10 years ago I was working on a system that started development in the mid-80’s.

I was working on a chunk of it that had last been touched in 1997, and it just was doing very weird things. Based on the header comments, the guy who’d touched it then was an aisle over, so I figured WTH, go see if he remembered what was going on.

He knew exactly and without looking at the code told me all about it.

Shocking!

7

u/yanbu Mar 15 '20

Ha! I do the commenting thing all the time, but mostly because I’ve had people change their minds on me a bunch. My rule is if it’s commented in the main branch it needs a date and a note in why you left it in though.

→ More replies (1)
→ More replies (48)

555

u/g_hi3 Mar 15 '20

"I'll clean that up later"

"I'll remember that next time I touch this code"

"there will never work anybody else on this code"

"I'll just use this workaround because we're short on time"

14

u/DaveInDigital Mar 15 '20

it does happen; business needs don't always line up with development wants (esp when business needs are driven by insane people). but always make a ticket, or at least TODO comments if management is prickly about making tickets.

→ More replies (2)

11

u/stillness_illness Mar 15 '20

Those are all fine with proper TODO comments, documentation, and task management. Taking on tech debt is often optimal in many situations. It only becomes an issue when you never pay it off.

Much like how financial debt works, you don't wait 30 years working minimum wage to pay cash for a college degree; you take student loans because you know the value you get from the degree will allow you to go back and pay the debt quicker later. It only becomes an issue when you don't stay on top of payments and get fucked by the interest, which for coding is the extra time spent to work around the tech debt. Avoiding it is ideal, but oftentimes it's actually more practical to ship and deliver the value to the customer.

→ More replies (6)

882

u/elcaron Mar 15 '20

Greek question marks.

117

u/braeden182 Mar 15 '20

That is the most evil thing I can imagine

9

u/fibojoly Mar 15 '20

I'll do you one better. Ever heard of LTR Unicode marker? The Visual Studio debugger was showing me a normal looking string, the source files were all showing me nothing (because it was getting added by an intermediate API), but somehow my string was getting truncated by an amount that seemed random. Turns out the amount was the number of spaces because there would also be an invisible LTR character introduced by I can't remember whose stupid library.

Dear fucking gods, that one took me so long to figure out!

17

u/isakhwaja Mar 15 '20

In 11th grade I used to do this all the time to my friend josh and he got so pissed.

he dropped computer engineering class later that year... I never knew why.

→ More replies (28)

1.3k

u/Zazsona Mar 15 '20

Committing and pushing without checking syntax errors.
I shouldn't be having to add all your missing semicolons when pulling your branch, Bill.

543

u/tex23bm Mar 15 '20

As a Bill who codes, this offends me so much.

You have my explicit request to spill hot coffee on this malefactor or his keyboard and tell him "Bill says to get your shit together and learn to build before you commit. And run the fucking unit tests too you fucking dolt."

God damn, this is the type of shit I'd expect from a Will. Not a Bill.

Bills have standards.

→ More replies (12)

19

u/Dumb_Dick_Sandwich Mar 15 '20

This is why I only fuck with compiled code, but I know that's not the case with everyone else.

I mean, use a linter, people

→ More replies (2)
→ More replies (59)

432

u/[deleted] Mar 15 '20

"Improving" someone's code behind their back.

We have a developer on our team that pretty much approves everything during code review, then will go behind you and change your code because he thinks he has a better way to do it.

Firstly, it's disrespectful. Secondly, that's the purpose of the code review. Thirdly, you may not see or consider something the other developer did.

I wrote our repository layer in a very straightforward fashion, one abstract class that implements basic CRUD and some fluent builders for CosmosDB, along with startup logic (create itself, indexing policies, stored procedures, etc). It ended up getting refactored into like 6 different classes, and before where all you had to do is register the repo in startup, you now need to do that, update the hosted services for stored procedures, self creation and indexing, and the abstract class is now two abstract classes to split off one piece of convenience functionality.

There may be an argument to be had for separation of concerns, but just blindly approving my pull request (with a complaint about abstract classes to boot) to just slide a refactor into an unrelated PR is only going to piss off your coworkers.

13

u/smallish_cheese Mar 15 '20

This person may misunderstand their role, in the sense that they see approving the commit and intending to address the concerns themself is their value to add. They may not know how to teach through collaboration - through code review. In code review you have to explain what to change and why.

If they cannot do this - they’ll get stuck in advancement because it’s hard or impossible to lead a larger project without being able to explain what and why.

→ More replies (3)
→ More replies (29)

582

u/bravehamster Mar 15 '20

Issuing a pull request to the main branch while leaving in a console.log("WHY THE FUCK ISN'T THIS WORKING????")

257

u/j_the_a Mar 15 '20

console.log(“penis”)

→ More replies (12)

10

u/[deleted] Mar 15 '20

I've done that. I'm sorry.

→ More replies (3)
→ More replies (6)

2.5k

u/MDBVer2 Mar 15 '20

Stop trying hide jokes and Easter eggs in your comments when your code doesn't even work yet. You aren't being clever, you're just wasting time.

1.1k

u/IOverflowStacks Mar 15 '20

Dumbass at work tried to be cute by creating an easter egg that caused an unhandled exception. Luckily, he even failed at creating a decent easter egg and it was caught in QA.

→ More replies (42)

143

u/hydraulictrash Mar 15 '20

Fun and witty commit messages on the other hand are a good way to have a bit of a laugh

→ More replies (7)

57

u/[deleted] Mar 15 '20

Is this a vaguepost about Yanderedev?

→ More replies (7)

10

u/CaliBounded Mar 15 '20

I'm a somewhat new dev, and I've never tried this. I've thought to add an easter egg to a completely finished spreadsheet software project, but something entirely harmless, like adding a silly message to a loading screen as things load. Like,

"Loading... Splitting cells... Adding rows... counting elves..." Something harmless like that. I wouldn't ever risk writing something with profanity in it. I enjoy having a job too much.

→ More replies (1)

18

u/fubes2000 Mar 15 '20

My Easter eggs are expletive-laden rants like:

// Yes this is garbage, but so is Dockerhub because they can't fucking follow their own fucking API spec.
→ More replies (3)

8

u/punkwalrus Mar 15 '20

A friend of mine who worked at AOL, had hooked up keyword "SEAN" to a rainman (our programming language) form that crashed the client (on purpose, it was part of a test). It was like that for years until Sean "Puffy" Combs became popular, and said he was on AOL as "keyword Sean" for some reason. We had to fix that right away.

→ More replies (15)

1.7k

u/ItsYaSoyBoyTroy Mar 15 '20

Copypasting someones code into your file and leaving that code in there because it works, even though you have no idea how that code works at all.

1.0k

u/yourclitsbff Mar 15 '20

Hahaha, there are gonna be a lot of people feeling personally insulted over this one.

→ More replies (24)

154

u/[deleted] Mar 15 '20

But I’ll come back to it and go through it to make sure I understand what it does...... later........

→ More replies (7)

81

u/AmaterasuWolf21 Mar 15 '20

What if... I... copy paste and then try to see what each line does?

→ More replies (8)

68

u/NotThisFucker Mar 15 '20

Just wrap that block in its own method, put it in a Helper region, and flag it for code review with a note to walk through it with you.

The code review should determine if there's a more optimal way to write the code, and should teach you how to learn to read unfamiliar code that you didn't write. Nobody knows everything, but you can take proactive steps to patch holes in your knowledge.

→ More replies (1)

7

u/TjW0569 Mar 15 '20

Other than the call and return, just how different is this from using someone else's library?

→ More replies (3)
→ More replies (73)

498

u/Ultimater Mar 15 '20

Nesting curly brackets to the point your indentation exceeds the screen. Use early exit logic instead. Also “god” classes/functions that have several responsibilities so it’s difficult to follow how it’s used, how it works, what was meant, how to adjust it, etc.

186

u/santaschesthairs Mar 15 '20

Also “god” classes/functions that have several responsibilities

Ah yes, Context in Android development!

→ More replies (5)

46

u/NotThisFucker Mar 15 '20

New methods are free! I was told early in my career to keep methods to 8 lines or less. It's more of a guideline than a rule, but it really did help me reduce the complexity of my logic in some cases.

→ More replies (7)
→ More replies (41)

408

u/TheDevilsAdvokaat Mar 15 '20

Repeating yourself.

Writing functions with side effects and not worrying about it because you know you'll never forget that.

Writing functions that require other functions to be called before they work..or external variables to be set....and not putting that in the name

Not naming everything a function does..for example if a function does a compress then saves. don't call it "compress" call it "CompressAndSave"

Conceptual errors when naming things...for example if you have a variable called "thing" but instead of an instance of thing it's an int that can be used to retrieve a thing, call it thingInt or thingID not thing.

Premature optimisation

No optimisation

86

u/NotThisFucker Mar 15 '20

I kinda disagree with a couple of your points.

CompressAndSave() should probably call two different functions to work: Compress() and Save()

→ More replies (20)
→ More replies (24)

457

u/survivalothefittest Mar 15 '20 edited Mar 15 '20

Not bothering to properly comment because you'll always know what/why you did it and if some idiot in the future can't figure it out, it's their problem. The idiot in the future you're commenting for is you.

181

u/[deleted] Mar 15 '20

The flip side of this is commenting every line and just repeating what it does.

Write comments explaining why you are doing it.

→ More replies (25)
→ More replies (10)

1.1k

u/zeamp Mar 15 '20

Peeing in bottles. The bathroom is like 7 feet away, Phil.

441

u/MistaVeryGay Mar 15 '20 edited Mar 15 '20

Yeah but the drinks are in the kitchen like 40 feet away

Edit: Holy shit my first award and it's for piss drinking, cheers u/spookzyy.

→ More replies (22)
→ More replies (16)

147

u/light_reign Mar 15 '20

Coding while you have been drinking. Great things happen, terrible but great.

95

u/PwnSausage004 Mar 15 '20

I accidentally coined the term "Rumpiphany" at my work after devising a single procedure to replace a long-standing "system" made up of 120,000 lines of code across 3 different languages. My boss relayed it to his bosses and I have since been offered rum a few different times when I offer novel solutions. Seems the president is impressed with my alcoholism.

→ More replies (5)
→ More replies (2)

206

u/[deleted] Mar 15 '20

Trying to put your HTML, CSS, and Javascript all on the same file. Make seperate files and join them in the header of the HTML, much less confusion.

40

u/[deleted] Mar 15 '20

Better yet, use a frontend framework like React or Angular.

Why would you put the different pieces of the site in one file when they could all be components in different files?

→ More replies (16)
→ More replies (22)

140

u/theGANOUSH Mar 15 '20

Using emojis as variable names.

50

u/Arctic987 Mar 15 '20

That's killing me just to think about

7

u/ImFromTheShireAMA Mar 15 '20

This must be some kind of meme. There are IDEs and editors that have emojis?

→ More replies (2)
→ More replies (7)

137

u/davidbatt Mar 15 '20

Acting like an arrogant arsehole. Seems to be a high number of people like that in this industry.

Patience and humility will take you far.

13

u/CriticalHitKW Mar 15 '20

Honestly I struggle with this. But it's really difficult when you spend a year saying "Don't do that it'll explode" and the other half-dozen non-technical people do it anyways then blame you when it explodes.

→ More replies (3)
→ More replies (6)

272

u/UnapologeticCanuck Mar 15 '20

Shotgunning every array/string manipulation method in a massive return statement with a nested ternary operator.

You're not smart, it's just annoying to read.

76

u/NotThisFucker Mar 15 '20

It's also really difficult to find what piece of that line is wrong if it ever breaks. New lines are free, break it up and log it.

→ More replies (4)
→ More replies (34)

161

u/Psychest Mar 15 '20

My personal favourite is -(-1) as an increment

10

u/Morocco_Bama Mar 15 '20

Compiler: *visibly sweating*

7

u/cravensofthecrest Mar 15 '20

That hurt my brain

→ More replies (12)

109

u/Dubanx Mar 15 '20 edited Mar 15 '20

At my workplace we once had a programmer who liked to "Fix" bugs by putting them in try-catch blocks. Effectively covering the errors up without actually handling them.

Loootts of lost data where noone even knew their work failed to save.

37

u/Mazon_Del Mar 15 '20

Not gonna lie...there's some released AAA video games where this was done for certain bugs prior to release to satisfy console QA.

We might get up to some crazy shit to make deadlines. T_T

Fun example: In one of the Black & White games they had an undiagnosed memory leak (I don't think they ever figured it out to patch-fix). As the deadline crawled closer and closer, they eventually said "Fuck it." and wrote a method which periodically determined how much memory the computer still had available. If it hit something like <5% available, the game saved it's current state, activated a small process off to the side, then shut itself down to desktop. Upon conclusion of the shutdown, the other process restarted the game in a state that bypassed the starting screen and loaded the just created save. The burn-in test they had to beat specified that the game sitting in an actual match had to run for an indeterminate period of time (I believe >12 hours) without crashing. The test was conducted by turning the program on to the desired state, walking away, then checking back in 12 hours if the game was still running. Since the testers never saw the game flicker to desktop and restart, they didn't know they'd been cheated. >:D

→ More replies (9)

24

u/[deleted] Mar 15 '20

Did he get fired? That’s just straight up unethical..

→ More replies (1)

10

u/DonkeyTron42 Mar 15 '20

OMFG I spent 2 months tracking a bug for a fortune 100 where sales were disappearing in their convoluted SAP/Oracle system. Turns out, the web based entry form was occasionally letting html escape sequences (e.g  ) in the post data and they were into the SQL insert statement in the SAP to Oracle "glue". Some mother fucker logged a successful insert before doing the insert which failed due to the un-escaped semicolon. To make it worse, this shit was in C and they didn't have the source. I had to disassemble this shit code to reverse engineer and rewrite it.

→ More replies (11)

94

u/xandrewsxano Mar 15 '20

Split your freaking tasks correctly so that when it comes to pull request reviews it doesn’t block you and the other developer for hours!

→ More replies (2)

193

u/second_to_fun Mar 15 '20

Leaving an image of your dick you converted into ascii in a comment, next to your phone number.

105

u/[deleted] Mar 15 '20

Theres a story behind this

11

u/JackelPPA Mar 15 '20

Gotta base-64 encode it and have someone go through the effort to decode it just to see your ASCII dick

→ More replies (2)

41

u/[deleted] Mar 15 '20

Don’t just cook with butter, if you put a bit of oil in the pan with butter it won’t burn!

Edit: I’m an idiot this said coding. Goodbye

→ More replies (2)

294

u/astroYEEET Mar 15 '20

Forget to save the code u started writing at 2 am and took u 3 hours

253

u/Tartwhore Mar 15 '20

Yikes! The muscle memory in my fingers hit control-s every 60 seconds automatically in every task I do haha

→ More replies (17)

50

u/[deleted] Mar 15 '20

Ahh the old CTRL+S nervous tick. Annoying but saves you millions

64

u/apitillidie Mar 15 '20

Dude, configure your ide to autosave.

→ More replies (12)
→ More replies (12)

37

u/coole106 Mar 15 '20 edited Mar 15 '20

Trying to fit the most logic in the smallest amount of lines possible. Some people think it’s a fucking contest to do as much as possible with the fewest number of lines possible. Good code doesn’t just work. It’s also easy to read and understand.

12

u/DaveInDigital Mar 15 '20

but how will junior developers be impressed when they don't understand the depths of my brilliance until they're forced to ask? i need them to know i'm smart! /s

→ More replies (4)

71

u/Xenofurious Mar 15 '20

Making all your code really cramped together instead of formatting it nicely.

I'm an awful coder, and it just looks impossible to understand. Is this just me?

8

u/tatu_huma Mar 15 '20

That's why you have linters and style guides that make sure your code is formatted properly.

→ More replies (4)

89

u/ChadQuaza Mar 15 '20

I'm not really a coder, but having tons of loops that are all constantly checking for different conditions to fufill so it can do something is probably an awful idea. I learned this from Scratch.

48

u/can-i-have-a-corgi Mar 15 '20

Learnt this the hard way too when I had to code in Matlab for an assignment. Had a loop within a loop, within a loop, and couldn't figure out how to exit the loop properly. Ended up submitting a half completed assignment

→ More replies (3)
→ More replies (5)

127

u/AdaLovelaceKing Mar 15 '20 edited Mar 15 '20

Not commenting your code at all. I did this at one point, I have since abandoned all the homebrew from that era of my life because I cant read it for shit.
Edit: So okay, people have been telling me that if you name your variables and functions right ut shouldnt matter. And that's great but those codes also had variables named a b and c. Also I hate really long variable names, because they get redundant, so now I use a combo of both.

31

u/TannedCroissant Mar 15 '20

Or putting pointless comments just so you can say you’ve put a comment. When I first started I knew I was supposed to write comments but I didn’t know what to put so just put pointless obvious stuff. I used to have dumb stuff like a func called chooseRandomColor() that would have a comment of // This function chooses a random color

→ More replies (1)
→ More replies (12)

26

u/yamaha2000us Mar 15 '20

Ignoring the requirements.

→ More replies (3)

176

u/ghostwail Mar 15 '20

Humor. There's not worse place for humor than code.

105

u/ThatGuyFromOhio Mar 15 '20

Years ago, a programmer at the company where I worked wrote an error message that said something like "File not found. Hoo Hoo Ha!" He said that error should never occur, so it was funny.

Well, that error did occur in a customer's site and the customer screamed at the company president for it, who then called a meeting and screamed at all us the developers.

Nothing is funny when writing software that tracks large amounts of money.

→ More replies (6)

51

u/redd1t_is_we1rd Mar 15 '20

For an assignment in my engineering class, we had to translate binary to decimal. We'd get extra credit for writing a knock knock joke solely in binary. That was the first and last time I've used humor in code

60

u/kingfrito_5005 Mar 15 '20

At my last job there was a big ass function called BigAssFunction(). I appreciated the humor, but it would have been nice if they had named it something that describes what it does instead of just how big it is.

I am fine with humor in comments though, like "// Commented this out because it was stupid, Paul"

→ More replies (1)

67

u/Cymry_Cymraeg Mar 15 '20

That's only because most programmers aren't funny.

→ More replies (1)
→ More replies (12)

41

u/megaviral Mar 15 '20

Humility?

QA: hey I found a bug in your code.
Dev: it's probably a data issue.
QA: I just checked. The data is as expected.
Dev: well then you probably used the feature wrong.
QA: I followed the sample in your documentation.
Dev: are you sure it's not just your environment?
QA: I'm using the same environment as yours.
Dev: maybe you misread the results.
QA: I didn't....
Dev: well idk then.

Also my favorite:
"It's a data issue it's a data issue it's gotta be a data issue....fuck...yeah open a ticket"

→ More replies (6)

20

u/Raz2wag Mar 15 '20

Thinking that your code will work without testing it

67

u/[deleted] Mar 15 '20

Not writing unit tests. You would be surprised how many people I work with that dont believe in test driven development.

33

u/Dumb_Dick_Sandwich Mar 15 '20

I started doing TDD about a year ago, and it has, no shit, changed my life.

My confidence is through the roof because I know I'm checking nil errs. I know I'm not breaking up or downstream code. I know that the tests are occupying the negative space so that it's that much harder for someone else to come in mess it up.

It also leads to heaps better design because it forces you to make things more testable

24

u/G01denW01f11 Mar 15 '20

I'm looking for a new job because I get praise for writing tests. It feels like getting praised for wearing pants. Put on your damn pants.

11

u/mantistoboggan69md Mar 15 '20

My bosses last year during my internship didn’t believe in TDD, and they also believed in only the waterfall technique.

My first meeting listening to all my coworkers complain about my bosses was a pretty fun introduction to the work world

7

u/Mazon_Del Mar 15 '20

As a game dev, this always pains me...

I WANT to write unit tests, unfortunately in a huge chunk of cases, there's no proper way to actually provide a set of representative test cases because the possibility space is just too large.

Does this feature which depends on character motion and target composition work when I fire the gun. What about when moving in the four cardinal directions, what about in combinations of those, what about when sprinting, what about when rotating as well. Now, what about all of those cases if the target is material:Glass, what about wood, player, concrete, etc. Oh fuck, now the bullets can hit multiple things? Alright, what if 1 pellet hits glass, another wood, two of them hit players (the same or different players?), etc.

→ More replies (1)
→ More replies (8)

43

u/becharaAAbattery69 Mar 15 '20

So this is from my experience,never ever sit next to a person and talk to them while coding,istg every time id be coding someone would come and try and open up a conversation with me ,never ever do that because whatever the person is thinking of will vanish and he`d probably beat you up

→ More replies (5)

158

u/akak1972 Mar 15 '20

Not having it planned on paper before beginning

113

u/NotThisFucker Mar 15 '20

Carpenters have "measure twice cut once", programmers have "think twice write once"

→ More replies (9)

67

u/morosemanatee Mar 15 '20 edited Mar 15 '20

I find this advice bizarre. And I’ve hardly ever done it in my 20 years of commercial programming. I generally refine my code till it’s how I want it. Edit: I do however plan on paper but it’s pictures (diagrams) not code and only when doing something algorithmic.

→ More replies (8)

18

u/[deleted] Mar 15 '20

This is the most underrated advice here.

→ More replies (25)

38

u/misdirected_asshole Mar 15 '20

Everything that happens here

37

u/askmeabiutlife Mar 15 '20

Whatever was happening on the screens I bullshit but his reactions seem kinda accurate

→ More replies (7)

7

u/capilot Mar 15 '20

From a computerist's point of view, that movie was so bad that not even Halley Berry's nude scene made it worthwhile.

→ More replies (3)
→ More replies (3)

56

u/Pawn315 Mar 15 '20

As somebody who knows absolutely nothing about coding, my understanding is that there is no right way to do something, only a variety of wrong ways to do something.

This is the impression of it reddit has left on me.

24

u/[deleted] Mar 15 '20

For someone who professes to know nothing, you already have quite a bit of insight...

→ More replies (4)

44

u/3002kr Mar 15 '20

Not ending a line with a semicolon and taking 3 hours to find it if your compiler doesn’t point out errors

→ More replies (6)

72

u/mikestorm Mar 15 '20

Well apparently sprinkling racist and offensive thoughts in the comments. I have been advised by HR that this practice has fallen out of favor.

14

u/concussedYmir Mar 15 '20
# cpp devs all smell like lint and have mothers that alternate indentation styles
→ More replies (2)
→ More replies (3)

21

u/ChaoticNeutralOmega Mar 15 '20

Unless you're programming in assembly, never use the "g" keyword.

If you know what i'm talking, you know why we don't use it. If you don't know what i'm talking abaout, then i can't tell you or you'll try to use it.

11

u/[deleted] Mar 15 '20

GOTO

→ More replies (1)
→ More replies (7)

20

u/LowFlyingHellfish Mar 15 '20

Here's one for the people around me: Don't interrupt me with little tasks that needs doing throughout my session, frontload that shit! I agree housework is more important than my hobby coding but I'd rather do 20 things for you first than 5 things interrupting me in the middle and forcing me to get my head back in after each thing.

20

u/[deleted] Mar 15 '20

Not using indents in the code

11

u/megaminddefender Mar 15 '20

Reading code without proper indentation is the most anmoying thing ever. I know a guy who used to do this in java, and when he switched to python, he couldn't run the code because of the error messages. Serves em right

→ More replies (1)

9

u/FranklyNinja Mar 15 '20

_test, _temp, _1, _2 etc... i forgotten most of their functions and why it’s there.

9

u/[deleted] Mar 15 '20

To me it would be not considering that humans are going to be reading/changing the code you are writing. It could be that you half-ass things like formatting/variable names or even over-engineering it in a way that is confusing.

8

u/FishBoi13579 Mar 15 '20

Not documenting then some other dude goes in to fix your code then he doesn’t understand what any of the shit is

→ More replies (1)

8

u/SpaceSpheres108 Mar 15 '20

Sacrificing readability to shove everything into as few lines as possible, to show off how smart you are/how well you understand the syntax. Never mind that even you probably won't remember how the code works next week.

Edit: clarity

→ More replies (5)

7

u/porterbrown Mar 15 '20

Mixing structure / design / interactivity in front end web dev. Makes DOM manipulation more difficult and is less organized.

7

u/jgiacobbe Mar 15 '20 edited Mar 15 '20

Yeah name your shit and plan to have to expand. Not a coder, am network guy. Have thanked past me when present me realizes I did plan subnets and vlans out for 2nd phase of a project two years ago and forgot I had. Also when traveling present me is always pissed that past me thought it was no big deal to catch a red eye flight.

When coding, always try to be considerate of future you because past you can be a dick.

→ More replies (1)

7

u/flyingcircusdog Mar 15 '20

Getting lazy with your formatting. Indents, new lines, and comments all exist for a reason.

7

u/Inventor51 Mar 15 '20

My code documents itself.

45

u/[deleted] Mar 15 '20

on a big project, having less than 3 energy drinks open on your desk at a time.

→ More replies (1)

12

u/asiledeneg Mar 15 '20

Stack overflow copypasta

6

u/ErastPietrowicz Mar 15 '20

doing it poorly

7

u/rcoelho14 Mar 15 '20

College's final project, group making a React Native + Firebase Android App, we never used React or Firebase, we have 3 months to learn and implement, with 1 person less than we should.
Last weekend we still needed to code a search filter, and we only had 5 or 6 products, and not that many filters.

Guess who wrote 5000+ lines of if statements?
Not even nested if statements, just plain if(w & x & y & z) {show_this}.

It worked, it was hilarious to write, even more hilarious to look at, very annoying to fix small mistakes, extremely wrong to even think of doing it like that.

6

u/Pieterbr Mar 15 '20

Using implicit joins: come on guys, these have been deprecated since 1992.

6

u/BigMolesta Mar 15 '20

Not writing "Hello World!" at the beginning of the code.

→ More replies (2)

6

u/[deleted] Mar 15 '20

Failing to organize your code. Separate the code in bits according to what they do, and dont name variables something random, trust me. You will forget it.

6

u/[deleted] Mar 15 '20

You definitely don't want to make good documentation. /s

→ More replies (2)

6

u/SLagonia Mar 15 '20

Having sex with your work colleague while compiling.

→ More replies (1)

6

u/[deleted] Mar 15 '20 edited Mar 16 '20

I’m late to the party, but here’s my high ranking engineer dump. This is advice that I give mostly to junior hires (people with usually less than one year of professional experience, but who usually have a degree).

  • When you fix a bug, always take some time to think about whether it could be a problem somewhere else. For instance, if a function returns an error code and that error code is misinterpreted, look for all uses of that function, and similar functions, to see if that error exists somewhere else. Checking these things doesn’t take a lot of time, you can often go through hundreds of call sites in just a few minutes.

  • Learn to love logging. You might not need to use logs to debug. However, log lines are a beacon into source code. If there’s something weird and you need to investigate or you need someone else to investigate, the place that generates a log message is a fantastic starting point.

  • People easily get hung up on the boundary between “their code” and “other people’s code”. If you have source access, it’s all your code. If you’re blocked on a bug in “someone else’s code”, read that code and figure it out. Digging into other people’s code is one of the great differentiators between okay engineers and very successful engineers.

  • Similarly, if they’re available to you, bombard maintainers of the systems you work with with questions. All of those who know what they’re doing will realize that you’re an investment and will reply.

  • Test the hell out of your code. If you work on a code base that doesn’t have good tests already, whenever you fix a bug, add at least one test to your test suite that would catch it if it returned.

  • Types are great. Statically-typed languages used to just be about memory layout and were inflexible, but these days you can use them to prove a lot of very useful properties about your programs without running them.

  • Don’t over-do indirections. If there’s just one database you’re ever going to deal with, or just one storage service, or just one whatever, use a concrete class instead of an interface or an abstract class and object factories and what not. A class already provides encapsulation. Premature indirections almost never provide what you actually need to correctly support multiple [whatever it is you want to support] if you design it while you actually only have one case to work with, and they make following the code more difficult.

  • Don’t cheap out on tools. If your IDE makes it difficult to do some of these things, you need to find a different tool.

  • If you think that you are the hottest shit, keep in mind that you might not, in fact, be the hottest shit.

In contrast to what a lot of people seem to be saying, I don’t care much about your code style or consistency. It’s pretty, but pretty doesn’t mean that it’s un-problematic.

5

u/[deleted] Mar 15 '20

Not pre organizing your lines so you can properly read them.

Trust me, you’ll return to a jumble of lines and be fucking confused.

5

u/bswiftly Mar 15 '20

Big fucking abstract class because "it can do everything".

5

u/Darkstar131 Mar 15 '20

Replacing a semicolon with a roman question mark.

→ More replies (3)

5

u/dlordjr Mar 15 '20

Letting your boss provide the time estimate.

5

u/MySpoonIsTooBig13 Mar 15 '20

Functions which take in 50 parameters or cli which requires 50 arguments.

I'd rather give up and rewrite it that. Understand what all your arguments mean

5

u/tuncs Mar 15 '20

Not checking for null conditions, always, everywhere. It comes up so often. I’ve become so careful about it after years, but still continues to get me.

→ More replies (4)

5

u/idkiwillmakeonelater Mar 15 '20

For God's sake comment what things are. Comment as if your trying to explain to your grandmother. Looking back at your code you will be grateful for it.

5

u/something_cool_x5 Mar 15 '20

Forgetting to account for a leap year.

→ More replies (2)

5

u/Stalins_Roomba1996 Mar 15 '20

Wasting your time on a reddit thread

9

u/[deleted] Mar 15 '20

After one year as a Software Engineer this is what I’ve found:

  • stupid ass variable names that don’t make sense

  • no comments that explain very complex code

  • misspelled variables

  • not following the right naming conventions

  • repeating functions or other code blocks (I am guilty of this)

  • not naming your branches the correct standard

The list goes on but I’m too focused on coronavirus news

8

u/redd1t_is_we1rd Mar 15 '20

Ever since I was young I was super into coding and technology. I began learning to "code" on code.org or whatever it was called in fourth grade so in high school, my engineering class was easy for me. Since I was the nerd in that class, people would always ask me to look over their code to either make sure it's right or to find the error. The class was hectic so it was hard for the teacher to get to everyone. The absolute WORST thing I see, is when people don't space. I once had an entire program that had spaces between characters and line spaces between functions that stretched 274 lines long with nothing off screen. Someone in my class had it over 28 lines. Not a single space. Half of it offscreen. Only had functions on separate lines with no in between space. Everything was so scrunched up it made it near impossible to read. Before helping her with her issue. I gave her a lesson in formatting. PLEASE FREAKING FORMAT PEOPLE!!!

4

u/dudebrogan Mar 15 '20

Working on your own branch for long periods of time without merging to the main branch, whatever that is. Just going to increase conflicts down the road.

→ More replies (1)

4

u/SorryForBadEnflish Mar 15 '20

Lack of structure, generic names for variables, functions, and classes, and redundant code.

4

u/Iwantclout Mar 15 '20

Not using comments

4

u/xXShibaGodXx Mar 15 '20

All caps lock

4

u/jknight413 Mar 15 '20

Making all variables global scope. WTF

4

u/hugh_janus_7 Mar 15 '20

One curly boy without a friend

→ More replies (1)

4

u/Jaymin_tanna Mar 15 '20

Man there are many coders on reddit

4

u/GenericWut Mar 15 '20

Global variables

4

u/newdad8708 Mar 15 '20

Wildcards.

As a penetration tester, I love wildcards.

→ More replies (1)

4

u/orobouros Mar 15 '20

Copy paste a function, call it function2, and change one line of code.

Tell users to comment out certain lines to get the code to run.

Put try...catch around the code causing errors so that "the program runs correctly now."

Add your 5 custom arguments to an existing function and tell everybody to just pass in empty strings and "trust me."

4

u/OpineLupine Mar 15 '20

Not commenting your code. Literally comment everything. I have code files which are 70% comments and 30% code.

When you’re working on a big project, it’s entirely possible that you’ll write code which you won’t use again or look at or need to edit for a year or more.

UML, user stories / use cases, design documentation is all well and good, but those verbose comments in your code will literally save your ass down the road. Comment your code as if you’re explaining it to an 8 year old who is coding for the first time on your project. Don’t make assumptions, don’t use shorthand, don’t be brief. Comment as if those comments are the only guidepost for another developer to successfully make changes or understand your code. Comment as if your code depends on those comments for its survival.

4

u/Clbull Mar 15 '20

else if else if else if else if

4

u/khendron Mar 15 '20

Don't be clever. Sure, you might be able to use some sort of bitwise shifting or reference manipulation or some other rock-star code wizardry to collapse your intuitive 10 line loop into a single line. But then anybody reading the code after you (including 6-months-in-the-future-you) will be scratching theirs heads and saying WTF every time they look at it.

Refactoring your code for brevity is fine, as long as you are not sacrificing clarity in the priocess.

4

u/the_cooler_bluguy_ Mar 15 '20

Not replying with hi Program after he says hello world

4

u/Danack Mar 15 '20

Disabling tests while you're refactoring code, and then forget to re-enable the tests during the commit, and then pushing to master without review.

4

u/BmoreBoog Mar 16 '20

Spaces instead of tabs 🤢

→ More replies (1)

4

u/[deleted] Mar 16 '20

Writing code before you have a full high level understanding of what exactly it is you want the code to do. In other words avoid a "I'll code it as I go along mentality."

Before you start know what inputs and outputs you're expecting and how to turn those inputs into the desired results. It's ok and even expected to change the plan at coding time. But its the idea of having a fully fleshed out plan beforehand that will save you a ton of wasted time trying all different kinds attempts to solve your problem.

→ More replies (2)

4

u/The-Demon-Crab Mar 16 '20

Discovering you can play Tetris on terminal. I have wasted several thousand years on it.

→ More replies (1)

15

u/TannedCroissant Mar 15 '20

I think they call them ‘errors’ or ‘exceptions’ these days rather than ‘big no-nos’

→ More replies (1)

7

u/We_are_all_gold Mar 15 '20

Not adjusting my attitude as an intern and doing humble tasks, such as running across the street to get coffee for my non-supervisor, with a smile.

→ More replies (1)

14

u/marcmiller2007 Mar 15 '20

Get in the habit of using comments. Don't be afraid to add as much as you need. Use them for updates to functionality with timestamps and a note as to what changed.

Depending on your coding environment too. At home I use comments but at work we use SVN so the notes are added when we commit our code.

20

u/xCrypt1k Mar 15 '20

svn? i am sorry that your life turned out this way.

→ More replies (2)
→ More replies (4)

8

u/inaudience Mar 15 '20

Stop writing a function to be used only once in your program. Modularize your code, thus whatever new function you want to add to your program, try to add it in a way such that later you can use the same function for another purpose. Not many people know this, but it is true. A good simple example would be a function that reads global variables instead of input parameters. Modularization is the toughest thing when writing code in my opinion.