r/ProgrammerHumor • • 1d ago

Meme dynamicProgramming

Post image
5.3k Upvotes

140 comments sorted by

View all comments

319

u/NomaTyx 1d ago

a lot of design patterns sound scary with all the big words, but they boil down to stuff like "don't put two unrelated things in the same inheritance tree, dumbass". like just don't be stupid and you're probably using them unwittingly

137

u/BufferUnderpants 1d ago

So many programming principles are just reminding people not to put the goddamn oranges in the same bag as the apples, but they don't want to even look at the fruit

41

u/NomaTyx 1d ago

yeah like the facade design pattern is incredibly obvious and is partially already covered by "don't repeat yourself". Like, why would you want to write every step of a 12 step process multiple times when you could just write one function that does every step and then just call that? Sometimes these things beget explaining again, but it's certainly something

17

u/Advos_467 1d ago

i feel a little vindicated reading all these because i always felt some of these GoF design patterns were kinda obvious like façade and adapter lol

40

u/bpkiwi 1d ago

People often misunderstand the idea of design patterns. Instead of 'here is a pattern you can use', think of them as 'we found a pattern that lots of people already use (because it makes sense), and we gave it a name so everyone can talk about it easier'

7

u/Advos_467 1d ago

yeah that makes sense. I've really only been exposed to them mostly in an academic environment so it always felt like the former to me (I never actually read the book either)

3

u/BastetFurry 1d ago

All these design patterns are nice and all until you are on a cheap microcontroller with 8k of flash and, if lucky, 1k of RAM and you begin to think about using bare assembler instead of C. ;)

1

u/IlliterateJedi 1d ago

Yeah but where do you put the OrangeBagFactory and the AppleBagFactory?

17

u/DiamondDramatic9551 1d ago

don't put two unrelated things in the same inheritance tree, dumbass".

Maybe prefer composition over inheritance in the first place. 

3

u/zyxzevn 1d ago

A lot of the design patterns come from the lack of certain features in the language.

In the OOP Smalltalk language many of those patterns are a waste of time. Because they can be replaced with a simple Closure or Lambda. Smalltalk was based on Lisp.
Java and C++ did not have that at the start. So we have visitor-pattern, iterator-pattern, etc.

2

u/NomaTyx 1d ago

yeah that too, i was specifically talking about the bridge design pattern, which i really feel like is what most people would do even without being taught it.

7

u/dustyhome 1d ago

It's like the Art of War. It has basic things like "the army needs food" in it. When a field is new, someone has to write down and name the obvious things so everyone can then build on a shared understanding of the basics.

1

u/Lithl 23h ago

The concepts in the Art of War weren't new to actual generals, it was written for idiot nobles pretending they could be generals.

1

u/guyblade 13h ago

To be fair, that's been a recurring problem for most of history.

6

u/DezXerneas 1d ago

observer pattern

"yeah just call the function you want when it's needed, and don't poll for information"

singleton

"why use many [object] when one [object] do trick?"

2

u/NomaTyx 1d ago

Right? Like a private constructor for it is just common sense

3

u/Naturage 1d ago

I have had similar problem in a different field once; chatting to someone who's an expert in economics and knows a lot of fancy terms for statistical analyses, while I knew hardly any as a student in maths.

Turns out, they have a dozen terms to describe different ways to use basic-ass linear regression to test if somethings' statistically significantly different.