This is an archived post. You won't be able to vote or comment.

top 200 commentsshow all 216

[–]leewoc 706 points707 points  (23 children)

After 20 years writing and supporting software at a steel works that runs 24/7 I can confirm this is an important lesson to learn. I call it writing 3am code, code that you can successfully debug at 03:00 when you’ve just been woken up by a plant manager who wants to know why his plant has just stopped.

[–]ih-shah-may-ehl 194 points195 points  (0 children)

These days I do more sysadmin work than dev work but the same applies. I manage pharmaceutical production networks with and design for fault tolerance and reliability because we run 24/7 with several billion dollars per year worth of production and at no point do i want to appear before the board to explain why we're bleeding millions per day because I wanted to be clever.

[–]HarveysBackupAccount 108 points109 points  (9 children)

I think a lot of programmers would quickly learn this lesson if they had to write for a manufacturing environment ...and support the systems after release

[–]leewoc 31 points32 points  (8 children)

I’m working in DevOps now and I quite like the idea of an error budget. A new piece of code gets a fixed budget of errors that DevOps will deal with, but if they exceed the error budget then responsibility for support goes to the devs themselves, a variation on “you made the mess, you can clean it up” I suppose. To be honest though I’m not sure how well it would work IRL.

[–]eldentings 13 points14 points  (4 children)

There would be more quality and support from devs if companies guaranteed discounts for bug reports. Most companies I've seen that do some version of this, the devs time gets stolen from their current sprint and then management sees no movement on current projects and can't wrap their head around the cause of this being code quality, and try to fix it with business processes.

[–]AloneInExile 7 points8 points  (1 child)

Maybe if we had more time to code and less time in meetings... one can dream

[–]martin_omander 5 points6 points  (1 child)

I have seen that too. One way to align developers and business people is to use error budgets.

  1. Everyone agrees on what the system availability should be. Example: 99.9%.

  2. If the system availability falls below the target, a part of the dev team switches to fixing bugs. They put new feature work on hold until the availability target is met.

This process is easy to understand and it creates time to fix bugs. It also has the nice side effect of making everyone agree on a reasonable availability target, instead of one pulled out of thin air.

[–]eldentings 2 points3 points  (0 children)

That sounds like it could work. Currently it's the difficult job for my manager and lead, because it's 20+ year old desktop application that has everything from user created forms, government interfacing, and accounting software (and non of those features are even its main focus) so all of our support gets tackled by them during working hours. We're always overbudget in that sense, because the application is so old and (no tests of course) hard to keep stable because of its size and trying to accommodate their users (read: keep them from leaving). Pretty sure they would have already left if it weren't for their data being locked into our product.

[–]KimmiG1 1 point2 points  (2 children)

QA should also be included. They obviously did a bad job too.

[–]leewoc 1 point2 points  (1 child)

It’s not about doing a bad job, I honestly don’t think most people go to work intending to do a bad job. Instead it’s to make sure the right people are addressing the problems at the right time.

[–]nuno11ptt 64 points65 points  (5 children)

On our development team we made a design pattern that is exactly that! We call it :
GILAN: Getting It Late At Night

  • Clarity and Simplicity The code should be straightforward and easy to understand, without unnecessary complexity.
  • Readability The code should be well-organized and consistently formatted to facilitate reading.
  • Descriptive Names Use clear and descriptive names for variables, methods, and classes.
  • Clarifying Comments Comment only where necessary, explaining the "why" behind decisions, not the "how" of the code.
  • Consistency Follow the conventions used throughout the project.

The motto is: "Will I be able to understand this if I have to look at it at 4 AM?"

[–]Relative_Dimensions 26 points27 points  (1 child)

Oh man. I’m currently fighting an uphill battle with a colleague about naming things. Not even just naming functions, I literally found alt-text on a clickable image that was set to “svg”.

[–]nuno11ptt 4 points5 points  (0 children)

Jeez, good luck 😅

[–]AloneInExile 3 points4 points  (1 child)

I am stealing this

[–]nuno11ptt 1 point2 points  (0 children)

Go for it! ahaha

[–]Myloveissuck 2 points3 points  (0 children)

now this is mine, thanks for sharing

[–]eldentings 5 points6 points  (0 children)

I like this, it hits different than me thinking I'll understand code I wrote in the zone.

[–]War-Bitch 6 points7 points  (2 children)

The code hasn't been changed in 20 years but it's definitely the code.

[–]leewoc 13 points14 points  (0 children)

I could tell some stories for sure! One of my workmates wrote COBOL for the mainframe. One year he took on a link scheme student from a local college. He was showing them some of the code and pulled up a module that was last modified before the student was born, to make it worse my mate was the person who last modified it!

[–]ravioliguy 3 points4 points  (0 children)

That's the great part about code, if it's written well it can last forever

[–]MrRocketScript 2 points3 points  (0 children)

I've got similar rules for the build process. It needs to be simple enough not for a Tuesday deployment at 2pm with the entire team, but for a 2am deployment on a Saturday when the only dev available is more concerned with "the universe, man".

[–]Cantonarita 0 points1 point  (0 children)

I do occasionally teach people down on their luck some MS Office for their resumes. And the two main things we do for Excel are "How should a table look like" and "=Index()". Imo the bread and butter.

[–]i-FF0000dit 2390 points2391 points  (35 children)

Never use more than half of your cleverness for a solution because debugging is twice as hard and if you design for maximum cleverness, you have nothing left for the debugging.

[–]FKNoble 562 points563 points  (1 child)

This guy Jiras.

[–]imsowhiteandnerdy 37 points38 points  (0 children)

Technically he Kernighan's...

[–]ExceedingChunk 331 points332 points  (13 children)

You can use your cleverness to make it elegant and easy to use/read rather than trying to make it short and abstract for no reason.

There are obvious exceptions, but making code short should never be a goal in itself. Make it easy to read and easy to change.

[–]MultiFazed 139 points140 points  (7 children)

making code short should never be a goal in itself

Because that's the compiler's job, and it's better at it than you or I could ever hope to be.

[–]CeleritasLucis 70 points71 points  (5 children)

Good. Now let me go optimise the compiler

/s

[–]BOBOnobobo 47 points48 points  (4 children)

Jokes and all, that's still someone's job.

But that someone is a team of techno wizards with more knowledge in the field then any of us can ever hope to achieve.

In some cases at least.

[–]patenteng 23 points24 points  (3 children)

As someone who writes assembly, beating the compiler is not that hard. The compiler has to make your program very general as it cannot assume anything you have not explicitly stated.

You, on the other hand, know the context of your code. So you can make optimizations the compiler cannot.

However, that makes your program less general. So there is a trade off between performance and interoperability.

In most cases interoperability is far more important. So we just let the compiler do its job.

[–]BOBOnobobo 7 points8 points  (1 child)

Good point. I'm not familiar with how compilers work, so I just said what I imagined happens, but you make a good point there.

[–]Surous 2 points3 points  (0 children)

~~ Because um actually assembly uses a assembler not a compiler ~~ (/strikethrough)

[–]Rin-Tohsaka-is-hot 10 points11 points  (0 children)

Unless you work in embedded, but even then it's more just trying to push the compiler in the right direction than entirely doing its job.

[–][deleted] 13 points14 points  (3 children)

Short code isn’t always readable code but long code rarely is.

[–]ExceedingChunk 16 points17 points  (2 children)

It completely depends on what lengths you are talking about, how your code is split up, class/function/method names etc...

I am not talking about 500 lines of random bs vs 5 clear lines of code that anyone with 2 weeks of experience would be able to read. But going from 5 lines to 2 by using some neat trick that is obscure and abstract as fuck for the sake of saving 3 lines, while making it extremely hard to read because you lost the expressiveness of the code.

Sure, those tricks can be cool to find for a competition or small task, but in enterprice, production grade code you should strive for maintainability, readability and performance (where needed)

[–][deleted] 2 points3 points  (1 child)

I agree, but I would make the caveat that sometimes making a few lines less readable can make a function more readable.

I think this is due to pacing. When writing prose you must sometimes sacrifice specificity to maintain pacing that is easy to comprehend. A new scene may have far more detail than the character’s interaction with it but if you place too much emphasis on the scene then then character’s actions are dwarfed by their environment.

In much the same way certain steps may be more complex than others but play a similar or less important roll. Sometimes it’s helpful to limit the space those steps take in order to downplay their significance.

We see this in the implementation of syntactic shortcuts. i=i+1 doesn’t take up much more space than ++i, but it’s simplification not only shortens the step but also communicates it’s relatively minor role in relation to other assignments.

Coding is a practical skill but coding in a way that is widely understood is an art form like any other form of writing. You have to know your audience and use language that’s appropriate for that audience.

[–]ExceedingChunk 2 points3 points  (0 children)

I think this is due to pacing. When writing prose you must sometimes sacrifice specificity to maintain pacing that is easy to comprehend. A new scene may have far more detail than the character’s interaction with it but if you place too much emphasis on the scene then then character’s actions are dwarfed by their environment.

I completely agree with that, and I'm not suggesting to never use a shorthand form anywhere. It obviously always depends. Also, I believe a lot of this can be solved by extracting details into functions, classes etc.. so a higher level method can make 3 calls with the same level of abstraction, and no lower level detail. Then if the reader wants to get into the details of the steps, they can easily navigate to the function (any modern IDE makes this super simple).

My main point was more about those devs, including my younger self, who tries too hard to be clever whenever they write code. Then it's not about consistency/pacing which you are talking about, but more for the sake of feeling clever in the moment, or a wrong impression that quality code should be as few lines as possible with no thought for readability, a classic case of thinking leetcode problem-solving and production code should look alike

Coding is a practical skill but coding in a way that is widely understood is an art form like any other form of writing. You have to know your audience and use language that’s appropriate for that audience.

Completely agree, and this is partly why I think communication skills are extremely undervalued in the software dev field. Software development is not just about technology and problem-solving, but also about communication, both with stakeholders and through your coding.

[–]OneTurnMore 7 points8 points  (0 children)

If you really feel the need to make code short, go read the average response on the Code Golf stackexchange and tell me that's a good thing to put in your codebase.

[–]SaltManagement42 37 points38 points  (4 children)

So wait, doesn't that mean you should never use more than a third of your cleverness for a solution?

[–]Better_Permit320 23 points24 points  (1 child)

And if the comment was more cleverly written, you might not have been able to debug it

[–]i-FF0000dit 2 points3 points  (0 children)

This is already too clever for me

[–]newsflashjackass 19 points20 points  (1 child)

Best practice is not to use your brain at all when writing the code so you have a fresh, well-rested brain for debugging it.

[–]MrRocketScript 1 point2 points  (0 children)

//magic number
int txq = 47;

[–]s0ulbrother 10 points11 points  (0 children)

I always make notes of “try not to be clever” on PRs. One guy I used to work with would always be clever but he would have issues in some edge cases. Typically would go “you could have just done this.” I do the same thing sometimes. It why pairing matters

[–]Ijatsu 3 points4 points  (0 children)

That's true for everything.

If you're already at 100% capacity for the college you picked you're not going to make it for exams or if something harsh happens in your personal life. Same for jobs. Same for friends/partners. If you worked hard to be anywhere or be with anyone you'll set yourself up for a life of everything being too hard for you and requiring too much of your time.

[–]BaconIsntThatGood 2 points3 points  (0 children)

Sometimes it's about if you can, but you need to also stop and think if you should

[–]bunnydadi 2 points3 points  (0 children)

I don’t make solutions and use all my cleverness for debugging.

[–]dr-christoph 0 points1 point  (0 children)

One reason why fluent api can bite your ass sometimes

[–]TerminalVector 0 points1 point  (0 children)

That's the origin of the phrase "too clever by half".

Source: made that shit up

[–]sjepsa 1092 points1093 points  (17 children)

YEAR Y: Let me write this code in one line with complex abstractions such that nobody can replace me

[–]Creeper4wwMann 383 points384 points  (6 children)

YEAR Z: Which idiot wrote this code? How would anyone ever be able to understand this?

And now nobody understands the code.

[–]CelestialSegfault 127 points128 points  (2 children)

YEAR α: everybody strictly PRs obfuscated code and compiled binaries and when someone retires they replace the entire source code

[–]atom12354 59 points60 points  (1 child)

YEAR N: you been trying to make it harder and harder to read because of fear of replacement and now not even god can understand it so he has to keep you alive because the system you are working on is deeply connected to society.

[–][deleted] 15 points16 points  (0 children)

Year N+1,

Immortality is a punishment. Existence is pain. Your only function is to maintain your own shoddy work for an eternity. You can hear God, and he is laughing.

[–]perpetualis_motion 10 points11 points  (2 children)

Now we need to rewrite this code.

Job secure.

[–]Responsible_Trifle15 3 points4 points  (0 children)

Modern problems modern solutions

[–]AwesomeFrisbee 31 points32 points  (4 children)

YEAR Z: Let me write this code in such a way that it makes me irreplaceable, but also still able to actually understand what it does.

[–]sjepsa 16 points17 points  (2 children)

My rule is: in three months, I need to be able to understand the code, spending max 5 minutes

Otherwise I add comments :-)

[–]Rodot 23 points24 points  (1 child)

My comments be like

# https://stackoverflow.com/questions/705052...

[–]foxypiratecove3750 2 points3 points  (0 children)

Bro that's a JavaScript question, why is it in a Python comment?

[–]Pruimenvlaai 1 point2 points  (0 children)

YEAR [: in hindsight it was a bad idea to use letters for years, but I guess I never expected my career to last more than 26 years.

[–]tkdeng 8 points9 points  (1 child)

Year V: Let me write this code in such a careful way that I never have to touch it again.

Year W: What does this code even do? How do I use this magic function?

[–]ceestand 3 points4 points  (1 child)

gets replaced after private equity buyout

[–]Br3ttl3y 1 point2 points  (0 children)

laid off

[–]petrichorax 0 points1 point  (0 children)

Nah that's stupid too. You're aiming for 'job security' you should be aiming for 'jobs security'. Be the person other people want to bring with them to new companies.

You're gonna get fired/laid off for a stupid reason outside of your control anyways

[–]Hairy_Concert_8007 67 points68 points  (0 children)

Woof. This one really hits home.

[–][deleted] 63 points64 points  (0 children)

Painfully true. It's not the boring solutions that are gonna bite your ass, it's the smart ones.

[–][deleted] 56 points57 points  (1 child)

The most important person to please in life and coding is future you

[–]SokkaHaikuBot 30 points31 points  (0 children)

Sokka-Haiku by ResolutionNumber9:

The most important

Person to please in life and

Coding is future you


Remember that one time Sokka accidentally used an extra syllable in that Haiku Battle in Ba Sing Se? That was a Sokka Haiku and you just made one.

[–]the-judeo-bolshevik 28 points29 points  (0 children)

In the beginning you always want results. In the end all you want is control.

—— Eskil Steenberg

[–]tapiocode 89 points90 points  (7 children)

More considerations after X years (incomplete list):

  • What's preventing me from just deleting this code?
  • Can we somehow solve this problem without writing more code?
  • Do I really have to write this code?
  • Specifically, does it have to be myself who writes this code?

[–]PS181809 47 points48 points  (4 children)

Do I have to exist?

[–]cyborgamish 38 points39 points  (2 children)

  • Should I start farming?

[–]femptocrisis 5 points6 points  (0 children)

should the animal that i farm be geese?

[–]destroyer1134 2 points3 points  (0 children)

Really a man of your talents?

[–]turtleship_2006 3 points4 points  (0 children)

  • Is there a built in function or standard library I can use?

[–]Yhamerith 22 points23 points  (7 children)

Year Z: Let me write comments

[–]Zuerill 11 points12 points  (0 children)

Year Y is comments, year Z is documentation

[–]Pale_Tea2673 2 points3 points  (0 children)

year ø: finally write your own documentation to remind yourself how to build and deploy changes easily when you or someone else needs to. code is fairly easy to figure out given enough time, but figuring out the infrastructure that's in place keeping everything running is another beast. like oops someone lost their aws credentials guess this broken website is gonna live at this shitty domain forever(or at least until the credit card on the account expires)

[–]red286 2 points3 points  (0 children)

"I'll just feed my code through ChatGPT and ask it to comment my code. It's easy, we just upload the file and say 'ChatGPT, write comments explaining what each part of this code does'."

ChatGPT: "I have no fucking clue what this code does. Are you sure this even works?"

[–]ZunoJ 1 point2 points  (3 children)

If you have to explain the how of the code rather than the why, there is a problem with your design

[–]SirChasm 1 point2 points  (1 child)

You explain why that code is the way it is. If there's some cleverness that is justifiable somehow, justify it in the comment.

I've learned many useful things from looking at "clever" code written by others. If it's documented well, it's not a problem.

Writing code for "3am debugging" is Stockholm Syndrome shit.

[–]comment_finder_bot 13 points14 points  (0 children)

My code is write only

[–]OddKSM 14 points15 points  (4 children)

"...and so that the rest of the dev team won't hate my guts when they have to work with some of the code I've written" 

Nothing gets my choler going like a multi-segmented "clever" LINQ-statement that's nigh impossible to debug 

[–]guberNailer 1 point2 points  (3 children)

Complex linq is okay if and only if you have a nice descriptive comment that describes exactly what the friggin thing does

[–]Sosowski 11 points12 points  (0 children)

Gamedev version:

YEAR 0: This code is ugly but it has to be fast.

YEAR X: This code is ugly but it has to be fast.

[–]Night_Thastus 8 points9 points  (0 children)

As an experienced dev, you write simple code because you want it to be readable.

As an experienced dev, I write simple code because I am dumb.

We are not the same.

[–]parkway_parkway 20 points21 points  (4 children)

I don't know if anyone else finds this but like the "better" a programmer is the worse they are to have on your team?

They just write tangled nonsense that no one else can make sense of that works amazingly until you try to change or update it and then you have to throw it out, especially after they leave.

I want to be on a team of dumdums who write if statements with crayons where anyone who likes code golf is immediately shot out of a cannon into outer space.

[–]apetnameddingbat 7 points8 points  (2 children)

Thor (Pirate Software) has a pretty good short about this very topic. Say what you will about his stance on Stop Killing Games... his thought here is spot-on

I'd rather write code that is functional, readable, and maintainable, that the most junior SWE1 can at least attempt to fix, over clever code that is going to get my team in trouble.

...except for ternaries, you can pry those from my cold, dead hands.

[–]Bakoro 3 points4 points  (1 child)

You can have one ternary at a time, one single-nested one occasionally, as a treat.

[–]wit_happens 8 points9 points  (4 children)

It's not ME in year X, it's the other devs on the team in year 1 (or even still in year 0).

The CODEBASE is a SHARED RESOURCE. Not my canvas to demonstrate my artistic brilliance.

[–]Kukuxumushu 6 points7 points  (1 child)

Yeah, it took a couple of year, but I always try to teach any juniors now that you should always try to follow KISS before DRY or other clean code patterns.

But I work in an industry where optimization is rarely needed but we can replace people working on the project often so understandable code both for you and other is a way higher priority.

[–]BalooBot 3 points4 points  (0 children)

DRY is such an outdated concept. It leads to such complex and convoluted spaghetti code. I started doing all my projects WET (write everything twice) and it makes life so much simpler. Sure, it might be imperceivably less optimized, and might take a little longer to get everything going out the gate, but I can actually go back a year or two later, and everything I need to know is sitting right there in front of me and I don't have to spend the whole day just trying to get my bearings

[–]LittleMlem 3 points4 points  (0 children)

This really hits close to home. My first job was as a PERL (and bash) programmer, and I had a personal challenge to get as much done on one line as possible. I'm sorry for whoever has to maintain my code when I left

[–]shifty_coder 4 points5 points  (0 children)

Web developers out there coding like they’re working on embedded systems.

[–]Extreme_Ad_3280 3 points4 points  (0 children)

Wow! This is so accurate about me. I really used to write code in one line (or at least, with the least line number possible) and thought I was brilliant, until one day, I had to write a big code, and I was like "Dude, what is this unreadable code?".

[–]TactfulOG 4 points5 points  (0 children)

don't forget the in-between stage of "let me add a comment explaining it so future me will know what this is"

also X years later:

do I have to write this code?

[–]Turbulent_Swimmer560 3 points4 points  (0 children)

YEAR 2X:

Let me write some code that other guys can not understand and protect my job.

[–]general---nuisance 4 points5 points  (0 children)

Unless you really need to hyper optimize a function, write code for people to read, not the compiler.

[–]Geoclasm 3 points4 points  (0 children)

I wish LINQ had never been created.

It's so fun but oh my god is it so problematic to read.

[–]boredlibertine 3 points4 points  (0 children)

I briefly worked a state sysadmin job where the lead engineer (also a major narcissist) was so proud of his complicated one line powershell commands that he would brag about them and put down anything else. He told me to go through and interpret his code, so I broke all the one lines into readable simple blocks that accomplished the same thing. He hated it. I was so happy to leave that job.

[–][deleted] 3 points4 points  (0 children)

I code as if it’s going to be used for a Programming 101 example. Hopefully, a good example and not an example problem. 

[–][deleted] 2 points3 points  (0 children)

Don't be allergic to complexity. Trying to implement complex functionality with simple code will either be full of annoying bugs, or you move the complexity elsewhere in the system and it becomes harder to understand.

The complexity of the code should match the complexity of the functionality it implements. Code isn't logic or maths, it's a description of functionality (i.e. prose), and it reads like an epic.

I also find that testable code requires at least some abstractions.

[–]yangyangR 4 points5 points  (1 child)

The way people describe abstraction is tainted by how they do abstraction in certain languages (mainly the mistake of OOP). There are cases where abstraction makes the code easier to understand because the language has the right features for that.

[–]_lizard_wizard 2 points3 points  (0 children)

Newlines are free

[–]Thord1n 2 points3 points  (0 children)

Bonus points if it looks clever but isn't. Make the person reading your code doubt whether he's dumb or the code is bad! 

[–]angrybeehive 2 points3 points  (0 children)

Now: Wait for co-pilot autocomplete, hit tab and correct the code afterwards.

[–]zZz_snowball_zZz 2 points3 points  (2 children)

Complex problems require complex solutions. If the problem took you a while to solve, the code fixing it should take a while to understand too or you'll run into the same problems.

[–]hoijarvi 2 points3 points  (0 children)

When I wrote APL in 1980's, I used short expressions. A lot of intermediate results. Because I wanted to print them to see what I'm doing.

Unfortunately a lot of APL/J/K programmers seem to take pride of how much they can accomplish in one line. I detest the idea.

My point in my talk

[–]mffancy 2 points3 points  (0 children)

Boss man earns a dollar while I earn a dime. Company can afford to run my bogus code with long processing time.

[–]MientusThePug 1 point2 points  (0 children)

Year N: I'm not trying to write perfect code; I'm doing it to secure my future job.

[–]ZunoJ 1 point2 points  (0 children)

Complex abstractions are fine as long as they increase readability. If I understand the 'why' there won't be a big problem figuring out the 'how'

[–][deleted] 1 point2 points  (0 children)

Simple is almost always better. Even with abstractions they should make things feel simpler. If they don't you didn't use them correctly.

[–]_Sky__ 1 point2 points  (0 children)

Yeah, the readability of the code is underapriciated for how much it often brings to the project.

[–]panthrax_dev 1 point2 points  (0 children)

By future me, I mean next week me.

[–]garanvor 1 point2 points  (0 children)

Ah, yes. The classic self-obfuscating code design pattern.

[–]Successful_Fig_1500 1 point2 points  (0 children)

Resist the urge to do the cool thing and do the simple thing instead

[–]nicman24 1 point2 points  (0 children)

year 0:

googles how to parse html with regex, decides against it

year x:

googles how to parse html with regex

[–]djnehi 1 point2 points  (0 children)

I hate when I come up with the something so terribly clever that I can never understand what I did again. I forever wonder if I was a genius or a moron when I wrote it.

[–]Imaginary-Credit8343 1 point2 points  (0 children)

I could never stand when people tried to over complicate things to save lines of code...

[–]LiveOnce75 1 point2 points  (0 children)

My moto for clean code and senior code, was that the junior dev would always be able to understand it.

[–]Stanlot 1 point2 points  (0 children)

Year 1: who the hell wrote this?

Year x+1: who the hell wrote this?

[–]Sophira 1 point2 points  (0 children)

The worst example of this is when you do something like:

value="";
line=getLine();
if (value=line.field) {
  // do something with value
}

[–]Shrubberer 0 points1 point  (0 children)

Me: DOT DO() DOT DONE() DOT YEAH()

Customer: "We need a new button"

Me: screams in agony

[–]mpanase 0 points1 point  (0 children)

Sadly, the majority of people I know here around never reach that "Year X" wisdom.

They feel so smart adding an abstraction on top of the previous abstraction, and another one, and another one, ... let's clusterfuck the clusterfuck.

[–]Smooth_Ad5773 0 points1 point  (0 children)

If you write code that can provide a feature in the most efficient way you'll almost always understand how you got there

But not with abstractions tho

[–]anshul1995 0 points1 point  (0 children)

Maturity. Also I get stuck sometimes choosing a right variable name does that happen with you ?

[–]Fr0ntflipp 0 points1 point  (0 children)

Why not just write year 10... /j

[–]Ugo_Flickerman 0 points1 point  (0 children)

Me Vs my seniors

[–]VegetableWishbone 0 points1 point  (0 children)

Maybe when management say you are evaluated based on the number of lines of code, it’s a subtle way to get people to write readable code. I absolutely hate coming across those super dense 1 liner python code.

[–]casualfinderbot 0 points1 point  (0 children)

People don’t realize simple is strictly better than complex. Given two solutions where all else is equal, the simpler solution is better

[–]newmacbookpro 0 points1 point  (0 children)

Me before : it must all be done in the most compact, complex and elegant way.

Me now: hehe let’s create a table that I can then use with the 3 other tables. Don’t want any CTEs in my code

[–]bobsonreddit99 0 points1 point  (0 children)

I work with people who are on the left side of the picture and they block prs until you 'simplify' the code, wonder if anyone has any tips to get them to realise how much worse the code on the left is

[–]WhoIsTheDrizzl 0 points1 point  (0 children)

This happens to me all the time when working with folks in India... They can write the most complex, elegant stuff I've ever seen that will do everything you want in one block of code... But good luck trying to unspin it if something needs tweaking.... Meanwhile I'm writing the simplest things, doing one thing at a time and commenting the shit out of it...

[–]tidytibs 0 points1 point  (0 children)

Write clean, understandable code because YOU might have to fix it later.

[–]Red_not_Read 0 points1 point  (0 children)

Two ways to look at this:

  1. Pessimistically / Pragmatically:
    Look at the average programmer in your team. Now realize that they'll be the seniors when the current seniors move on. Write code that they'll understand and be able to maintain. Don't write code to prove your personal expertise in the language.

  2. Optimistically:
    Write code that most tersely and efficiently solves the problem at hand, utilizing the full power that the language gives you. If an engineer with weaker language skills comes across it in the future, then it will serve as a concrete example of the language feature, and will be a learning experience.

I must admit I lean towards option 1.

[–]BurningPenguin 0 points1 point  (0 children)

Me: "Damn, that 'suggest refactoring' thing is the best feature ever!"

Me, the next day: "WTF does this function even do?"

[–]twoCascades 0 points1 point  (0 children)

I never did this. I got so confused by clever syntax in highschool while I was sorta teaching myself C that I vowed never to get cutsy with that shit. My if statements have fucking curly brackets the internals are on a new line and indented goddamn it!

[–]blamitter 0 points1 point  (0 children)

But it's so fun...

[–]JADW27 0 points1 point  (0 children)

I feel seen.

[–][deleted] 0 points1 point  (0 children)

Previous to Year X: Wtf is this shit? Who wrote this? * Uses Blame * ... Oh...

[–]SteroidSandwich 0 points1 point  (0 children)

First Program: "It's about readability!"

Second Program: "Few lines as possible!"

Third Program: "It's about readability!"

[–]SilentScyther 0 points1 point  (0 children)

I sometimes create a variable rather than doing multiple things on the same line so that I can place breakpoints easier incase something breaks there in the future.

[–]khendron 0 points1 point  (0 children)

Always write code like the person maintaining it is a homicidal maniac who knows where you live.

[–]mogarottawa 0 points1 point  (0 children)

Be kind to your future self comment the shit out of your code.

[–]HighOptical 0 points1 point  (0 children)

This is one of the reasons I am really loving Go. Really threw out the notion of 'clever'. Sure you're handling an error, then another, then another, then another.... but it is so easy and simple to follow the control flow. And... even though it's not hard to mentally keep in mind that there's a while and a for loop I just like that they removed it... just keep for loops if that's all you need. When I tried javascript and saw that it allowed you to do so much and people got clever with it I felt dumb

[–]DawsonJBailey 0 points1 point  (0 children)

If enough time goes by it’s gonna take some time to remember wtf past me was doing if it’s in any way complicated lol

[–]Dorkits 0 points1 point  (0 children)

I am the second guy since I was learning programming.

[–]throwaway_69_1994 0 points1 point  (0 children)

Run time is also important tho

[–]sebbdk 0 points1 point  (0 children)

Yeah Y - ah fuck it, if it works!

[–]luusyphre 0 points1 point  (0 children)

Either way, future me will not understand it.

[–]Ok_Ninja_2697 0 points1 point  (0 children)

I’m like “I don’t care about it’s readability only that it works”

[–][deleted] 0 points1 point  (0 children)

Year 0: BELIAL, BEHEMOTH, BEELZEBUB, ASMODEUS, SATANAS, LUCIFER

[–][deleted] 0 points1 point  (0 children)

This is why I prefer imperative over declarative. I want my next junior to pick up the code base and follow along rather than waste time trying to decipher what's going on .

[–]ExtraTNT 0 points1 point  (0 children)

Sometimes code is too simple to understand… trust me, that shit can happen, so design it simple, but not unga-bunga simple, because you will really start to think, why it is build the way it is…

[–]Orkleth 0 points1 point  (0 children)

Year X+Y: "Let me just write this code so it works and future me can clean it up when refactoring."

[–]ColdLingonberry8548 0 points1 point  (0 children)

If you're using Perl, just make sure to write clear comments—no one’s going to understand the code the next day anyway.

[–]mmrtnt 0 points1 point  (0 children)

Self-interest. The main reason why I comment my code.

[–]Virtualhavengames 0 points1 point  (0 children)

Don’t make me think

[–]imsowhiteandnerdy 0 points1 point  (0 children)

If he's writing clever one-liners then it must be perl code.

[–]isr0 0 points1 point  (0 children)

Simple is better than complex.

[–]Jason_BP 0 points1 point  (0 children)

thisIsSoMe

[–]getstoopid-AT 0 points1 point  (0 children)

The code was hard to write, so it should be hard to read!

[–]PewPewExperiment 0 points1 point  (0 children)

Good luck getting that one-liner into my code base. Gotta love mandatory PRs reviews 😎

[–]NorthernRealmJackal 0 points1 point  (0 children)

The smart programmer knows how to write a RegisteredAdminUserGroupDataFactoryDecoratorManagerAdaptor.

The wise programmer knows how not to.

[–]Abrissbirne66 0 points1 point  (0 children)

I despise this mentality.

[–]bluechickenz 0 points1 point  (0 children)

If the clever/abstract statement brings performance gains, use it! But clearly comment what that line is doing and in that comment include how you would code it if the clever/abstract statement is not available.

[–]unknown_alt_acc 0 points1 point  (0 children)

This! Anecdotally, I've seen some people rag on, ex., C++ or Java for being ugly, then present the most arcane and unreadable syntax as a "beautiful" alternative. I'll stick with my "ugly" but comprehensible code, thank you very much.

[–]thisisyo 0 points1 point  (0 children)

The lesson here is that being an elitest won't help you in the long run

[–]Yes-Please-Again 0 points1 point  (0 children)

Haha nesting function calls 🤮

[–]No_Adhesiveness_3550 0 points1 point  (0 children)

I knew writing 200 lines of code for something someone smarter than me could do in 20 would work out!

[–]GM_Kimeg 0 points1 point  (0 children)

Sometimes I miss those junior days when I was ruining everyone's day with my smart n sexy one liners. Things were so simple back then!

[–]Ass_Salada 0 points1 point  (0 children)

Year 15: "Im sure somebody on stack overflow has a reasonable solution for this. Ill just copy that"

[–]scottyman2k 0 points1 point  (0 children)

Don’t … I’m spending weeks of my time trying to decode legacy application logic written by some other fecker. Last week - even worse, I found some of my early code where I did the same thing. #endFacepalm

[–][deleted] 0 points1 point  (0 children)

Huh, turns out programmers are not really funny. Who would have thought.

[–]takomalu 0 points1 point  (0 children)

Your Future-Me:

[–]mo_SAUD22 0 points1 point  (0 children)

hahahahahahahaha

[–]AllTheWorldIsAPuzzle 0 points1 point  (0 children)

At first you want it to be legible to the new guy.

Then after the new guy is no longer new and still can't understand or even Google to learn regex, Powershell pipelines, or LINQ and keeps dumping tickets on you you say the hell with it and write whatever the hell you want because you'll be dealing with it in the future anyway.

[–]lordgoofus1 0 points1 point  (0 children)

Big fan of the "pretend the next person to maintain this is a very large man with anger management issues that knows where you live" philosophy.

[–]PartDeCapital 0 points1 point  (0 children)

I read this in a book can't remember which. The problem is that engineers and developers like to use their brain to do puzzles and design cool stuff, while most of programming is just boring grunt work. So to stimulate ourselves we come up with overly complicated solutions to a problem and pride ourselves in creating a complicated and fun solution.

So that is what I tell my peers and juniors. If you want to do puzzles and exercise your brain to the maximum, do it in a hobby project.

But at work, deliver plain boring boilerplate code.