r/ProgrammerHumor • • Nov 25 '22

Meme Coding strategies

Post image
52.2k Upvotes

385 comments sorted by

View all comments

Show parent comments

656

u/sillybear25 Nov 25 '22
  1. Thoroughly field-tested code with all the weird exceptions, edge cases, and other discovered requirements covered: "This code is so complicated! It's not even worth refactoring, so let's just scrap it and start over."

  2. Rewritten code: "It used to frobnicate instead of mogrifying when you click the 'download' button after sorting the table by reverse priority order during a month with two full moons. The customer needed that functionality yesterday, get it fixed and pushed to prod ASAP."

  3. Several top-priority bug-fixes and tens of thousands of man-hours later: All the weird edge cases, exceptions, and unspoken requirements have been rediscovered and implemented. Go to 1.

208

u/No-Witness2349 Nov 25 '22

Occasionally you can genuinely find abstractions which make expressing and maintaining those requirements easier. Designing a high-quality rule system can be difficult, but often well-worth it, imo

87

u/CanadaPlus101 Nov 25 '22

That's the dream, isn't it?

6

u/BetterOffCamping Nov 25 '22

It is not. I've done it. Once you understand the complicated mess (often a big ball of mud or spaghetti code) you can identify the edge cases.

With an understanding of core design patterns, the core logic can be simplified, while edge cases can be moved to independent classes with a strategy pattern, chain of responsibility, adapter, or some other pattern.

Sometimes it can't be done that way, of course, but one usually can better clarify the edge case visibility and group it at the very least.

Edit: automated tests must be built that verify the new version output matches the old output.

→ More replies (1)

0

u/[deleted] Nov 25 '22

[deleted]

10

u/Malijaffri Nov 25 '22 edited Nov 25 '22

⚠️⚠️ Copy-Paste Bot ⚠️⚠️

This bot stole part of this comment, and it doesn't even make sense out-of-context: https://www.reddit.com/r/ProgrammerHumor/comments/z4ay66/coding_strategies/ixqmd60/

Report -> Spam -> Harmful Bot

Edit: I am a human volunteer. Check out my source code on Wikipedia.

6

u/CanadaPlus101 Nov 25 '22

So do you have this running on your main account?

7

u/Malijaffri Nov 25 '22

This isn't some kind of bot or script. I am a human volunteer, and this is something I do manually whenever I find something like this in the wild. I don't look for them either. I use this as my own account, and simply dislike the overflow of harmful bots these days. I have this message copied to my notepad (mobile user) and just copy it here and change the source link whenever I find one. I still hold out some hope that we can overcome this epidemic :)

6

u/CanadaPlus101 Nov 25 '22

Oh. You might want to change it to "human volunteer" like the image-to-text people do. Thanks for the hard work!

11

u/elon-bot Elon Musk ✔ Nov 25 '22

Due to unforeseen circumstances, you will now be receiving your salaries in Elon Bucks, accepted at any Tesla location!

107

u/DoktorMerlin Nov 25 '22

3. Several top-priority bug-fixes and tens of thousands of man-hours later: All the weird edge cases, exceptions, and unspoken requirements have been rediscovered and implemented. Go to 1.

You forgot that these top-priority bug-fixes (and feature-requests) are top-priority while coding but then this part of the software is never used once by the customer. 7 months later you are asked how the functionality works only to figure out that it has never worked in the first place because the SQL query is containing a syntax error

48

u/sillybear25 Nov 25 '22

Nah, the bug reports wouldn't exist if the functionality was never used by the customer. (You think we're spending money on QA when refactoring is "too expensive"? Ha!)

No, it's used roughly once every couple of years by the manager of the customer's purchasing department, who misunderstood the requirements relayed to them by the manager of the people who actually use the product.

5

u/[deleted] Nov 25 '22

[removed] — view removed comment

19

u/elon-bot Elon Musk ✔ Nov 25 '22

Why have you only written 20 lines of code today?

2

u/R3D3-1 Nov 25 '22

This is getting old.

Also: I wish.

2

u/cantadmittoposting Nov 25 '22

Bot commenting out of context

→ More replies (1)

1

u/nipss18 Nov 25 '22

i am triggered by this comment

31

u/tangentandhyperbole Nov 25 '22

Its funny how similar this is to architectural design.

Floor plan that incorporates all the required structural and client needs, is designed around real world products.

But you need to rotate part of it 5 degrees.

There is an overwhelming urge to reach for File > New

12

u/SooooooMeta Nov 25 '22

Go to 0, I believe. The zero/one indexing bugaboo never leaves us, even on Reddit.

6

u/sillybear25 Nov 25 '22

Ah, I'm on a third-party mobile app at the moment, so I forgot that the CSS probably has the numbered lists starting at zero because it's a programming sub. I would refactor it into a while(true) loop, but management says that's too expensive, so instead I'm just going to rewrite that comment from scratch in a few years and make the same mistake again.

1

u/kwertyoop Nov 25 '22

Crying in 2

0

u/[deleted] Nov 25 '22

[deleted]

2

u/elon-bot Elon Musk ✔ Nov 25 '22

Why haven't we gone serverless yet?

1

u/F54280 Nov 25 '22

Story of all software.