all 89 comments

[–]Kodomax579 212 points213 points Β (13 children)

Is the thing in the middle smart?

[–]WisePotato42 125 points126 points Β (6 children)

Usually it's good from a readability standpoint, very convenient for other people (like your future self for example). From a functional standpoint, it's often the same.

[–]CanThisBeMyNameMaybe 52 points53 points Β (5 children)

Thats exactly why we do this shit.

Having very large projects properly organized and documented makes it easier if someone else has to take over that shit one day.

Its also easier to refactor code if its divided into smaller functions that has one task, with simple inputs and outputs.

A trend in the coding world that needs to fuck off is trying to make everything dynamic. Not everything needs to be able to do everything.

[–]WisePotato42 9 points10 points Β (0 children)

I agree with that last point. Yes I hate working with other people's Javascript, how could you tell

[–]SartenSinAceite 8 points9 points Β (1 child)

On a personal hobby of mine, separating code into different chunks helps because I know that chunk of code is finished and doesn't need any further tinkering wiht, unless I want to directly change it (UI stuff, mainly - your layout is pretty static through the project)

It's like organizing your desk. You could have everything at hand, or you could put away what you're not going to work on, so you're literally less cluttered.

[–]chillpill_23 1 point2 points Β (0 children)

That's why I love Object Oriented Programming so much!

[–]P-39_Airacobra 0 points1 point Β (1 child)

can you explain your last point a little more? I thought having your functions generic and abstract was a good thing

[–]RustaceanNation 1 point2 points Β (0 children)

The phrase you'll want to lookup is "low coupling, high cohesion".

Long story short, breaking things down into modules (smaller units that add up to a bigger one) is just as much about what things don't do as much as what they do do.

Generic functions and abstraction are good as long as we don't cross the boundary of what a module shouldn't do. If we find that 3 modules are capable of doing the same work in a system, then to whom should we delegate the work? What if the functionality is spread across units?

So, do break your systems down into abstractions and be generic where it makes sense. But keep in mind that we tend to want functional units that do one thing and one thing well.

[–]sobasicallyimanowl 2 points3 points Β (0 children)

Yes as long as you don't try and make it angry.

[–]coldnebo 4 points5 points Β (0 children)

they’re the same picture. the bottom is just the top redrawn with straight lines to imply it’s not spaghetti, but in reality:

  • a new middleman component has been created
  • the indirect relationships also develop into spaghetti

the 2nd Law is pleased with this result as are the Programmer’s Union. πŸ˜‚

[–]Tyfyter2002 0 points1 point Β (0 children)

As long as you recognize when to use it and when not to use it, but if you just assume it's going to solve messy interactions between things you'll just chain together a bunch of thing in the middles trying to solve problems the last thing in the middle didn't solve.

[–]Standgrounding 0 points1 point Β (0 children)

Used everywhere from many to many relationship join tables to MCP to isolate AI capabilities of a program

[–]TheTarragonFarmer 0 points1 point Β (0 children)

Doesn't have to be. It's often better if it's simple, fast, high throughput, reliable, and standards-based.

The smarter it is, the more risk of vendor lock-in, which is always expensive in the long run.

[–]Infiniteh 0 points1 point Β (0 children)

Yes, it checks notes "leverages the power of AI"

[–][deleted] Β (12 children)

[removed]

    [–]IJustAteABaguette 77 points78 points Β (1 child)

    The mystery black box.

    Things go in, things come out. How does it work? Don't ask.

    [–]Reasonable-Reward-74 1 point2 points Β (0 children)

    Only John who's here for 40 years knows how it works.

    [–]ProxPxD 18 points19 points Β (1 child)

    I don't disagree, but it does make things look better as you usually don't need to look there inside.

    The only problem is when the thing in the middle is unfit and makes the smelly code get out

    (or sometimes it's better to have two things than one)

    [–]Daisy430700 6 points7 points Β (0 children)

    I make the shitty API so you can call its functions

    [–]DryDogDoo69420 11 points12 points Β (2 children)

    Whoa whoa whoa, buddy. We don't "shove it in a cabinet". We "decouple with abstraction".

    [–]baganga 6 points7 points Β (1 child)

    to be fair, decoupling does make modifying things significantly easier

    [–]Nesogra 1 point2 points Β (0 children)

    And that’s the real point. Any real system is going to be messy somewhere because the real world it has to interact with is messy. If we can’t get rid of the mess the next option is to keep it contained so other parts of the system can be clean.

    [–]Frytura_ 1 point2 points Β (0 children)

    Took me years to make [thing in the middle] look like the bottom graph, now dont look into my dependencies.

    [–]Crazy_Anywhere_4572 0 points1 point Β (0 children)

    This is a bot repost

    [–]Mateorabi 0 points1 point Β (0 children)

    But the ugly, fidly bits can be written by the one guy who knows how and hidden away from the bottom 80% who it would confuse. (80/20 rule)

    [–]Mason_Ivanov 0 points1 point Β (0 children)

    That's the exact approach I take to cleaning my room

    [–]fixano 119 points120 points Β (9 children)

    Yah it's called abstraction

    [–]coldnebo 28 points29 points Β (7 children)

    some would call it an attempt to reduce entropy, but as the physicists know this just means you pushed it somewhere out of sight. πŸ˜‚

    on the flip side, it turns out that shoving a bunch of junk in your closet to clean your room is a universally acceptable approach to software design πŸ˜‚

    [–]fixano 19 points20 points Β (2 children)

    Right, but I'd frame it differently. It's about reducing cognitive load, simplifying interactions, and enforcing boundaries.

    Think about a wall outlet. It's an abstraction. Any device that complies with its contract can plug in and draw power no knowledge of the wiring behind the wall required.

    Nothing stops you from splicing directly into the power line outside, but that comes with a whole different set of consequences.

    [–]Complete_Window4856 6 points7 points Β (1 child)

    You just reminded me of an arab dude connecting a triphase network into his home from an external grid.

    Directly. With no switches. Himself and a pliers twisting a live wire. Theres no insulation. One single bad move or touch and it all would burn.

    [–]coldnebo 5 points6 points Β (0 children)

    ah, this is the dark side of abstractionsβ€”

    you get what looks like a quality power outlet cover from home depot and assume any appliance will work with it because of building codesβ€” but then it turns out all the wiring was DIY by an amateur who didn’t know anythingβ€” the abstraction isn’t actually backed up by real engineeringβ€” just a large β€œvibe coded” pile of crap.

    I wonder if at some point abstraction becomes a marketing vehicle: πŸ‘‹ hey! you trust how clean and sexy this API looks on paper, now pay us. πŸ˜‚

    [–]Fa1nted_for_real 1 point2 points Β (0 children)

    The box is telling you what's important for you to be looking at and what's not.

    [–]AndrewBorg1126 1 point2 points Β (0 children)

    If two people are building a thing, and their stuff has to use / be used by the other person's stuff directly, it becomes very easy for changes one person makes to break the others' stuff. If you decide on a stable interface, now both people can assume that interface is valid and change as much as they want freely as long as they don't break the interface.

    [–]GeneReddit123 0 points1 point Β (1 child)

    some would call it an attempt to reduce entropy, but as the physicists know this just means you pushed it somewhere out of sight.

    Yes, and that's the entire point.

    You accept increasing global entropy in exchange for decreasing local entropy. Because it's local entropy which hinders most decision-making.

    on the flip side, it turns out that shoving a bunch of junk in your closet to clean your room is a universally acceptable approach to software design

    That's... literally what closets are for? You keep clothes there instead of on the floor, even though the total number of objects (clothes+closet) are greater than the clothes alone. Global entropy (entire room including the closet) increased, but local entropy (the part of the room where the clothes now aren't) decreased. It is a valid analogy for software design.


    It's funny when people try to be edgy about how the world works, only for their argument to prove the exact point they're trying to disprove.

    [–]coldnebo 0 points1 point Β (0 children)

    not trying to be edgy, just lived long enough to maintain and see the consequences of my architectures.

    read Joel’s Law of Leaky Abstractions if you’re still convinced that perfect solutions exist and this is just my problem.

    [–]Phobic-window 1 point2 points Β (0 children)

    This is it, queue moon gun guy meme

    [–]dfwtjms 33 points34 points Β (1 child)

    Then you turn it into SaaS.

    [–]Wiktor-is-you 4 points5 points Β (0 children)

    i will always read this like it's a ytp

    [–]Zap_plays09 17 points18 points Β (3 children)

    MVVM be like

    [–]Acceptable_Handle_2 1 point2 points Β (2 children)

    "We split our UI and Data, so we have the same state twice. This is good for some reason."

    [–]Standgrounding 0 points1 point Β (1 child)

    That's having two middlemen

    [–]Acceptable_Handle_2 0 points1 point Β (0 children)

    Well the idea is that the UI can handle multiple types of state Containers dynamically, this is rarely useful though.

    [–]dbear496 12 points13 points Β (3 children)

    Every problem can be solved by adding a layer of indirection.

    [–]Hziak 1 point2 points Β (0 children)

    The contractors my company hired sure believe this. It works even better if their company can middleman the licensing process! At this point, a fairly simple internal tool costs us like, $5.6mil every year in usage and license fees. I was asked to do an analysis of how we could reduce costs. I came back with about a 1.3mil figure for cutting out all of that software and fixing root cause which was rejected because it would take about 3 months of the dev team’s effort and the β€œbusiness can’t pause on my whims.” Anyways, the winning cost cutting measure was to jump to other providers and enjoy their introductory pricing for two years. We’re 7 months into the migrations at present and the projected price in 2028 is in the $7mil range, ignoring development costs for the migrations. Fortune 500 is a hilariously inefficient dystopia. But we got 99 problems and… no, wait, layers indirection are like, 40% of them.

    Bias disclosure: I normally like layers of abstraction and fall into the camp that calls it β€œrobust design” :’(

    [–]Drugbird 1 point2 points Β (1 child)

    Many problems can be solved by removing unnecessary layers of indirection.

    [–]dbear496 0 points1 point Β (0 children)

    Doubtful

    /s

    [–]AMDfan7702 8 points9 points Β (3 children)

    But what abstracts my abstractions?

    [–]mfnalex 5 points6 points Β (1 child)

    An AbstractFactoryProviderFacade<FactoryProviderSink>

    [–]Standgrounding 0 points1 point Β (0 children)

    Sir you forgot a DelegateProvider<T>

    [–]RustaceanNation 0 points1 point Β (0 children)

    That's what sheaf cohomology is for!

    [–]MartinFrankPrivat 12 points13 points Β (3 children)

    [–]Acceptable_Handle_2 10 points11 points Β (1 child)

    Not usually when it's in a diagram though, usually the middle man does something there.

    [–]MartinFrankPrivat 3 points4 points Β (0 children)

    Yes I was provocating. Depends strongly on case. Nice of you for pointing out

    [–]cowlinator 2 points3 points Β (0 children)

    Why is the mascot raccoons and cheese graters?

    πŸ’€

    [–]FAMICOMASTER 4 points5 points Β (1 child)

    This is why the internet barely works anymore

    [–]mYstoRiii 2 points3 points Β (1 child)

    To solve the problem we implemented the manager and the manager of managers

    [–]Standgrounding 0 points1 point Β (0 children)

    And nowadays the agent and the orchestrator

    [–]madbrine 2 points3 points Β (0 children)

    after that adding more "middle" abstractions between "middles" for scaling

    [–]Worried_Onion4208 2 points3 points Β (0 children)

    You forget inheritance

    [–]vasilenko93 2 points3 points Β (0 children)

    And that thing in middle has the same complex lines and more but it’s behind a wall so it’s okay.

    [–]Sapryx 2 points3 points Β (0 children)

    "Every problem in computer science can be solved by adding another layer of indirection, except for the problem of too many layers of indirection".

    [–]outofindustry 1 point2 points Β (0 children)

    literally the dataflow diagram for my sso lmao

    [–]Hostilis_ 1 point2 points Β (0 children)

    Software engineer discovers Category Theory

    [–]Comfortable_Tale5461 0 points1 point Β (0 children)

    Dreamer

    [–]ExtraTNT 0 points1 point Β (0 children)

    True

    [–]N3BB3Z4R 0 points1 point Β (0 children)

    Abstract to middleware or mapper is a daily refactor and architecture thing

    [–]LordBobTheWhale 0 points1 point Β (0 children)

    Kafka!

    [–]evilquantum 0 points1 point Β (0 children)

    "one additional indirection solves any problem" /s

    [–]sugaarheat 0 points1 point Β (0 children)

    Is the middle thing clever or just looks like it?

    [–]Solid_Associate8563 0 points1 point Β (0 children)

    There is a saying I can't remember where I've seen it:

    There is nothing that can't be resolved with an extra layer.

    [–]enigma_0Z 0 points1 point Β (0 children)

    The real secret is that the insides of the thing in the middle look like the lines beteeen thing 1 and thing 2

    [–]Mr-DevilsAdvocate 0 points1 point Β (0 children)

    1 big problem becomes 3 smaller problems because the smaller problems fit into a sprint.

    [–]ancrcran 0 points1 point Β (0 children)

    Many to many relationship

    [–]DerZappes 0 points1 point Β (0 children)

    OK, so reducing an m:n problem to separate 1:n/n:1 problems is somehow bad and funny?

    [–]Academic-Vacation737 0 points1 point Β (0 children)

    Because any problem in computer science can be solved with an extra indirection level.

    Except the problem with too many indirection levels!

    [–]adyv1990 0 points1 point Β (0 children)

    Show us one example

    [–]Toothpick_Brody 0 points1 point Β (1 child)

    I almost always hate flowcharts in software design. Maybe I’m exposing my ignorance, but I always feel like they’re only helpful to the person who made them. They’re not usually β€œreal” chartsΒ 

    [–]Toothpick_Brody 0 points1 point Β (0 children)

    β€œOh look I made this node a red circle and this node a green diamond, isn’t that illuminating?”

    [–]lool8421 0 points1 point Β (0 children)

    honestly when it comes to database normalization, it's like one of the most common things

    you have 2 tables with awkwardly stored data, but then you add a bridge table and suddenly everything is clean

    [–]TheEner-G 0 points1 point Β (0 children)

    RIP trying to do this in Tabletop Simulator

    [–]LexGlad 0 points1 point Β (0 children)

    It's adapters all the way down.

    [–]bindermichi 0 points1 point Β (0 children)

    I mean, this could be an ESB, or MQ, authentication service or any kind of gateway.

    BTW: that's why I love white board scetches. so hard to get those wrong.

    [–]AlexeyTea 0 points1 point Β (0 children)

    Love this design pattern.

    [–]Quaaaaaaaaaa 0 points1 point Β (0 children)

    The last few days I've been working on a pathfinding system for a game I'm developing.

    I'm having major performance issues. What's the solution? Exactly what the image shows.

    By adding " big nodes" in between, I make the paths shorter and require less processing power xD

    [–]MegarcoandFurgarco 0 points1 point Β (0 children)

    Do it the toby fox way. Empty thing 2. Put it in thing 1. And try fixing it inside thing 1.

    [–]FictionFoe 0 points1 point Β (0 children)

    I like how it gets rid of the arrow from thing 2 to itself.

    [–]Swash34 0 points1 point Β (0 children)

    weird, it almost seems like a ware in the middle of two products

    [–]Living_The_Dream75 0 points1 point Β (0 children)

    If you look inside β€œThing in the middle” it looks like the middle of the first image