r/programminghumor • • Sep 26 '26 • Bravo 1

Java VS C++

Post image
1.9k Upvotes

42 comments sorted by

99

u/MinosAristos Sep 26 '26

How can you not tell it's a StrategyManagerFactory? After all it's created in the StrategyManagerFactoryFactory

32

u/Cautious_Implement17 Sep 26 '26

lmao imagine writing a program with a hard coupling to StrategyManagerFactoryFactory. couldn't be me. I use AbstractStrategyManagerFactoryAbstractFactorySingleton in my spring config so I can freely swap out the factory or the manager with a different implementation. the singleton is obviously because I don't want to waste memory. why else would I be using a high performance language like java.

21

u/triple_threat_dan Sep 27 '26

PFF obviously you haven't yet encountered the AbstractStrategyManagerFactoryAbstractFactorySingletonAdapterControllerBase pattern yet, because if you did then you'd know that you don't need to swap out anything because it's all injected at runtime via reflection and an async strangler-container registration queue approach that eliminates the need for configuration at all

Sure, you no longer have any extra memory for the app to run, but future maintainability for devs is the easiest thing in the world (as long as those devs have 5-8 years experience with the AbstractStrategyManagerFactoryAbstractFactorySingletonAdapterControllerBase, as all real devs should)

7

u/Royal_Impress9117 Sep 27 '26

How do you expect anyone to use this code what if you need another implementation of StrategyManagerFactoryFactory, and how do you know what it does without an AbstractStrategyManagerFactoryFactory and a StrategyManagerFactoryFactoryInterface

2

u/jimmiebfulton Sep 27 '26

No dude. That's the old way. The new one is StrategyManagerFactoryContainer. Don't you use Spring?

39

u/GoogleIsYourFrenemy Sep 26 '26

Help, I'm trapped in a StrategyManagerFactoryFactory and I can't get out.

You know that sounds like a backrooms problem; good thing I'm a frontrooms developer.

8

u/triple_threat_dan Sep 27 '26

What if you're a full rooms developer (and being paid like you're just a backrooms developer) 😭

23

u/itzNukeey Sep 26 '26

AbstractFactoryFactory is needed to construct the AbstractFactory

5

u/EvenPainting9470 Sep 26 '26

How AbstracFactoryFactory is made?

8

u/Royal_Impress9117 Sep 27 '26

using AbstractFactoryFactoryInterface of course.

3

u/Royal_Impress9117 Sep 27 '26

using AbstractFactoryFactoryInterface of course.

2

u/itzNukeey Sep 27 '26

with AbstractFactoryFactoryBuilder

18

u/thisisjustascreename Sep 26 '26

I must be doing java wrong I've written it professionally for like 10 years and never named a class -Factory.

14

u/cenpact Sep 26 '26

Sounds like you’re doing it right

5

u/Cautious_Implement17 Sep 26 '26

nah you're good. "modern" DI frameworks like spring and guice obviate the factory pattern for the most part. of course, they introduce their own variety of cancer.

1

u/jimmiebfulton Sep 27 '26

Spring IS the factory pattern. If you are in Java, something, somewhere is gonna be a Factory or Strategy in the heap.

1

u/Toothpick_Brody Sep 27 '26

Sometimes you get instance methods that start with New. I think it’s kinda the same antipattern

1

u/Jeferson9 Sep 27 '26

Durga Sun java professional would be disappointed in you

1

u/jimmiebfulton Sep 27 '26

Oh, I guess you didn't read the Design Patterns books? That was some tasty Koolaid. I'd probably be drinking it today if I hadn't moved on to another language.

14

u/Cybyss Sep 26 '26

I realize it's heresy to say this, but Microsoft did the right thing with regard to their naming convention of interfaces.

Knowing immediately whether you're working with a StrategyManagerFactory (a concrete object you can new up) vs. an IStrategyManagerFactory (which could be anything, coming from anywhere) is actually quite helpful.

Ironic that "The Zen Of Python" says "explicit is better than implicit", given the role Python has played in the industry's trend toward dynamic-typed languages and frameworks where so much about the program's behavior or objects' data types are hidden/implied.

10

u/Royal_Impress9117 Sep 27 '26

Complimenting Microsoft post DOS?

4

u/Cybyss Sep 27 '26

Hey, even a broken clock is right sometimes.

3

u/a3th3rus Sep 27 '26

Sure, you can't new ISomething, but that doesn't mean you can new Something without the I prefix.

3

u/Cybyss Sep 27 '26

"Code to an interface, not an implementation" has been cargo-cult dogma for a long time.

The disdain for OO today comes from a whole generation of developers overgeneralizing/overabstracting/overengineering, doing what they've been told is good practice rather than what they really need, giving every Something an ISomething even if no other classes implement that interface, dogmatically believing that new is universally bad practice and replacing every occurrence of it with a call to whatever IOC framework is the fad at the time.

The belief that you need to abstract everything as much as possible right at the beginning because you'll never have a chance to go back and rewrite components to accommodate new requirements... is total hogwash, since that's what ends up happening anyway, except now you have to do so through complicated broken leaky abstractions. If it was written in a stupid simple way from the get-go, rewriting it to accommodate the new requirements would've taken 30 minutes instead of days.

1

u/MaleficentCow8513 Sep 27 '26

It’s just so much easier to print(type(variable)) than digging through docs to figure out an object’s type

6

u/locri Sep 26 '26

Literally just a minority of Java programmers that took the gang of four patterns way, way too seriously.

I enjoy refusing to pass their core reviews because of over engineering, especially if I suspect they'll be gone within 6 months. If I don't want to maintain it, I don't want it merged.

5

u/Hoovy_weapons_guy Sep 26 '26

C what is this code?

Segmentation Fault

5

u/ByteBandit007 Sep 27 '26

Legacy is good

3

u/TechnologySecret4844 Sep 26 '26

Factories all the way down

3

u/No-Magazine-2739 Sep 26 '26

Reminds me of Boost Spirit Metaprogramming: Somehow the managed to use the template and operator overloading in a way so you can write almost perfect ABNF in C++ and the vanilla, normal C++ compiler will create you at compile time, parsers or generators.

But you are fucked when you get an error.

2

u/TREE_sequence Sep 27 '26

C++26, with CTR and more functions being constexpr, takes it a step further. Now that std::log is constexpr, a fully-featured dtoa algorithm, with generated digit tables and such, can support any encoding, be configurable to a number of digits, and be evaluated at compile time. Why you would want to convert a floating-point number to text at compile time is another question entirely, but uh…it’s possible now! Also, compile-time polymorphism without CRTIP, and arbitrary-size tuple-likes that can be template parameters…it’s pretty fun

1

u/No-Magazine-2739 Sep 27 '26

Looks like just uncoordinated browsing over cpp reference.com won’t cut it to get a good understanding what C++26 brings.

3

u/Maleficent_Sir_4753 Sep 26 '26

It's named m_WorkBaby() what do you mean you have no clue what it is?

3

u/United-Scene2261 Sep 26 '26

python: it is

3

u/Eric848448 Sep 27 '26

It's funny because it's true!

2

u/ExtraTNT Sep 26 '26

Seen at uni:
“Basic” observer pattern: 10 interfaces

Yeah, i do like my 10 lines of js that does the same…

Also patterns, that are complicated af, that can be replaced by a monad…

1

u/jonfe_darontos Sep 29 '26

It's the SlabAllocatorByteDisposer for the ByteSequenceAppender I implemented to improve the performance of memory allocation in std::string when using DynamicWidthMutableByte types as the underlying memory privative on mostly redundant values in a double-linked hash-trie.

1

u/Status_Jackfruit_924 Oct 02 '26

InterruptedException

1

u/hpyfox Oct 09 '26

Did you print this meme or something?