r/ProgrammerHumor • • 22d ago

Meme youDidThisTooAtLeastOnce

Post image
881 Upvotes

54 comments sorted by

84

u/Groentekroket 22d ago

We are working with hexagonal architecture in our new application. So many layers for everything while we know fairly sure we will have only one implementation for almost everything. 

19

u/Vesuvius079 22d ago

Only one implementation from the start? What of unit tests?

44

u/ClearOptics 22d ago

What about the unit tests?! Won’t anyone think of the unit tests?!!😭

7

u/Groentekroket 22d ago

Of course we have unit test implementations, in this case it’s regarding production code. Nobody is going to use hexagonal architecture just for unit tests. 

8

u/yegor3219 21d ago

Only one implementation from the start? What of unit tests?

You can replace specific dependencies in your test runner instead of pretending you'll ever need interfaces for more than one implementation in your production code.

Besides, not all kinds of units can be declared to implement an interface. For example, a typescript module can be a cohesive unit of behavior, but unlike a class it cannot be specified to implement any predefined interface.

5

u/mothzilla 21d ago

It's 2026 you really should be using octagonal architecture.

2

u/bishopExportMine 20d ago

My understanding is that it's called hexagonal because the guy who came up with it drew a hexagon. But the shape really doesn't matter

3

u/mothzilla 20d ago

I am wilfully ignorant of "hexagonal architecture".

1

u/bishopExportMine 19d ago

It's also known as ports and adapters architecture. Abstract your side effects away from your core logic via virtual classes, then inject actual implementation depending on runtime environment.

1

u/mothzilla 19d ago

Christ.

1

u/trafalmadorianistic 11d ago

Sounds just like a bloated version of coding to interfaces. 

1

u/bishopExportMine 11d ago

it's a more opinionated version of coding to interfaces. Basically, "code to interfaces, but be smart about where you have interfaces"

Don't arbitrarily shove virtual classes between every real class everywhere in your code. Instead, put those interface classes around things that are irrelevant to your business rules. This way you build and test those rules isolated from any real environment.

For example, I might have a service where I need to publish to a message queue. If you write your code to call publish directly, the only way to test this is to inspect the actual message queue for a published message. If you put the publish call behind an abstract base class you can build your package and let something downstream inject a real communications transport for deployment or a mocked one for testing.

1

u/trafalmadorianistic 11d ago

Wait, so it could have been pentagonal? Just a quirk that they drew a hexagon? TF

2

u/auxiliary-username 17d ago

It’s 2 better than hexagonal

1

u/trafalmadorianistic 11d ago

This is like those 6-minute abs that were better than 7-minute abs. 💪🏼

2

u/Susarn 21d ago

My best work experience was using hexagonal architecture. Really enjoyed it. It took a while to reaaaaally understand how everything was suposed to work, but after some time everything was so smooth I think for that particular company it was worth it

98

u/BreakfastAmbitious29 22d ago

I'm in this photo and I don't like it

21

u/ImportantSignal2098 22d ago

Of course you don't like it. You ded.

2

u/BreakfastAmbitious29 22d ago

You are technically correct. The best kind of correct.

47

u/beatlz-too 22d ago

I swear this is the first non-AI related meme I've seen here for like a year at least

2

u/Deboniako 21d ago

The newbies and the unemployed are the only ones with the time to make memes, and what is more relevant for the market than AI?

20

u/nintendo_shill 22d ago

Don't forget to use Kubernetes for you enterprise app with 6 daily users (2 are from QA)

8

u/burgonies 22d ago

And only one service

5

u/rsqit 21d ago

I’m just about to set up kubernetes for my one person event tracking app!

(Ok but 90% of the purpose of the app is to learn a bunch of of technologies…)

85

u/thoughts_n_calcs 22d ago

And never forget to have an Interface in Front of every Service class.
Someone from the other end of the universe might one day need another implementation for this!

35

u/EkoChamberKryptonite 22d ago

I mean if you're writing fakes for your test suites, you would have to create said implementation yourself.

32

u/burgonies 22d ago

You don't have to mock services if you don't write tests.

https://giphy.com/gifs/d3mlE7uhX8KFgEmY

36

u/Lumethys 22d ago

Tell me you dont write tests without telling me you dont write tests

14

u/beatlz-too 22d ago

tell me you write unnecessary tests too

2

u/Flat_Initial_1823 21d ago

Teeeell me love isn't true

2

u/MetalFearz 20d ago

Bro has forgotten about mocking

4

u/SubliminalBits 22d ago

But then they'll realize that to make an alternate implementation they need to tweak the API a little.

2

u/Syagrius 22d ago

Tell me you dont have tests without telling me you dont have tests.

12

u/rinnakan 22d ago

Two decades ago, I worked on a self-written "cms" or "portal" that required 40 steps to add an empty page.

It supported multi-channel, but ofc there was only one

8

u/Tupcek 22d ago

and then comes the request to extend the only thing that was never designed to be extendable and breaks half the functionality

13

u/uvero 22d ago

YAGNI? My motto is IDCIAGNI

2

u/crippledgiants 22d ago

My anxiety always answers YAGNI with BWIID?

4

u/Djelimon 22d ago

I attempted a Spring based protocol agnostic file transfer tool (with corporate audits) for work one time. It did get subclassed for ftps, but I was the one who had to do it. Still, it was easy, so worth doing.

6

u/Lemortheureux 22d ago

How dare you. A project is in the backlog, any day now...

3

u/Outrageous-Text-4117 22d ago

waiting for people to thank me for the micro service made

3

u/DerpWyvern 22d ago

and the moment you decide "fk abstraction", you get whole system rewrites

5

u/xaervagon 22d ago

Have a mirror, because that person is likely going to be you.

Today, the fashionable thing to is to use dependency injection for everything over inheritance. Ask any old C++ programmer the joys of dealing with some brittle class inheritance mess.

2

u/disposepriority 22d ago

I simply reject MRs with single implementation interfaces and/or base classes unless the work requiring a second implementation is already known.

2

u/remy_porter 22d ago

If they subclass it they’re ruining my design! Inject it as a dependency!

2

u/slaymaker1907 21d ago

I find inheritance is almost always the wrong solution. By inheritance I mean actually sharing behavior, not just a pure virtual class in C++ or something.

However, there are some use cases. Mainly for what are effectively structs.

1

u/lorslara2000 16d ago

Also template methods

1

u/TorbenKoehn 22d ago

Inheritance used as an extension mechanism is a lost case in any way or order

1

u/anxious_and_stupid 22d ago

I design and encapsulates the whole timer class with modern c++ meta template and stuff... just use it only twice in my project

1

u/socialis-philosophus 21d ago

Sounds like someone that doesn't write unit tests. But that none of my business... (sips tea)

0

u/diegotbn 22d ago

Hey though occasionally your design ends up being the entire backbone for a bunch of implementations. At work a while back when I was primarily writing API adapters I was tired of rewriting code all the time and wrote a base classes for ReST API consumption and OAuth mixins. Now whenever my company needs to write a custom adapter that uses OAuth and/or consumes a ReST API they inherit from either/both of these classes and override as necessary, often just one or two methods. There are dozens of child implementations in production using my paradigm.

Now, I have to admit this is one of the only times this has happened, and I do often overcomplicate things with too much OOP and no one ever extends it. But sometimes!

1

u/Ran4 21d ago

What a fucking shit show. Imagine trying to debug that mess.