r/badcode • u/joujoubox • Mar 28 '21
other language Not sure if visual scripting is allowed, but this is quite literally the definition of spaghetti code
3.6k
Upvotes
r/badcode • u/joujoubox • Mar 28 '21
43
u/blitzwolfz Mar 28 '21
How did you make this
21
u/Father_Chewy_Louis Mar 28 '21
I actually think programming is less confusing than blueprints
73
u/calceto73 Mar 28 '21
But, it's work? That is important
5
u/fegauneg Mar 28 '21
Hi! I see that you are using blueprints un UE4. I have a question: where can I learn how to use it? I've seen a lot of tutorials but they pretty much don't describe how to practically use them, they only show complete code without explanation
4
u/gorangutan96 Mar 28 '21
What software is this?
7
u/literallytitsup69 Mar 28 '21
What the fuck is even going here? Is this some meta joke I’m too dumb to understand?
3
u/[deleted] Mar 28 '21
You could just set the cast node to a variable by right clicking on the end and clicking promote to variable. Same with the Float and the Name variables, and call it again when needed, it doesn't make it slower when you call the same variable again, it just cleans it up.
Also, for specific things you can collapse nodes by selecting the nodes that all do a specific function -> right click -> collapse nodes. Makes it more readable.
One last trick, don't forget about custom events when you need to execute some code multiple times.
Anyways, happy coding!
3
u/Pangocciolo Mar 28 '21
Is this the Blue print equivalent of if value=1 dosomething(1) elseif value=2 dosomething (2) .......... ?
554
u/[deleted] Mar 28 '21
scratch++
318
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Mar 28 '21
Image Transcription: Visual Scripting
[The image shows far too many coloured strands stretching left to right across a grid background. There are many nodes throughout the image, and the strands extend between them, some relatively short, but many others reaching out across the whole image in wide arcs like long strands of spaghetti. The strands end in further groups of nodes, all arranged in suspiciously similar patterns, like the spaghetti-and-node equivalent of one of Yandere Dev's if-else chains.]
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
158
u/SirNuke Mar 28 '21
https://blueprintsfromhell.tumblr.com/
2
u/einRoboter Mar 28 '21
This is not that bad imo, it looks very bad, but many visual scripting environments have no good way to make switch statements or reuse code efficiently.
It looks to me as though there are a handful of variables that are reused over and over (the long spaghetti strands from the left) these coul dbe simplified by hiding the wires and using namespaces or bundling the wires before splitting them in the end.
Usually this is where a small (python)script would come in handy to take over the work that is difficult to do in the visual scripting environment.
2
u/The_Alternate_Eye Jan 29 '22
Throw up
155
u/klekaelly Mar 28 '21
i remember that class. "Intro to simulating parallel universes", correct?
22
u/[deleted] Mar 28 '21
Holy crap imagine using “promote to variable”.
39
u/[deleted] Mar 28 '21
What’s crazy is this mess all gets compiled down to byte code in a pretty reasonable way and runs almost as fast as it’s C++ class equivalents.
5
u/leothelion634 Mar 28 '21
Blender 3d shader nodes be like
1
u/Random_182f2565 Mar 28 '21
What does this code do?
1
u/dhdylan Aug 09 '22
Let me guess, this is a SaveActor script?
1
u/NovaStorm93 Oct 05 '22
whats worse is that this looks like a bunch of chained if-else statements
3
u/[deleted] Mar 28 '21
Visual scripting is coding, it's just in a graph-theory format. That said, I really hate it when someone tries to describe it as "inherently cleaner" than text code. It's clearly not.
3
u/[deleted] Mar 29 '21
Cyclomatic complexity visualized
5
u/[deleted] Mar 28 '21
I used to work at an insurance company where they used a lot of SSIS packages.
Every single one of their package was like this. Some of them were so big that it took Visual Studio 15 minutes to open (I am not exagerating)
Visual scripting can definitely be considered "bad code" i think
2
u/Spynder shameless stealing content to r/YandereTechnique Mar 28 '21
r/YandereTechnique
2
u/FuryOfficial Mar 28 '21
Unreal Gang
2
u/truemario Mar 28 '21
2
u/wrexinite Mar 29 '21
Visual anything is bad code by definition
1
u/[deleted] Mar 28 '21
Relatable lol
1
u/oM4TY Mar 28 '21
Art
1
u/UrToesRDelicious Mar 28 '21
Ah yes, the small rectangles attached to the green lines, of course
1
u/[deleted] Mar 28 '21
I don’t know what’s going on because I don’t know any visual scripting, but, I would imagine this is what the event listener paradigm would look like for a single event.
1
u/OneTrueKingOfOOO Mar 28 '21
Oh man, you want spaghetti? Lemme go dig up some of my old MaxMSP patches
1
u/Tobbun Mar 28 '21
Looks like bird of paradise scripting. Now you just need several other scripts like that and you can make that whole terrifying tail fan.
1
u/circorum Mar 28 '21
Goto
1
u/[deleted] Mar 28 '21
This is abstract art
1
u/willhtun Mar 28 '21
All that for a drop of boolean logic
1
u/timmyhawkins3 Mar 29 '21
Lol this is actually very nicely structured if necessary. Probably could have been done in a simpler way but if it does have to be done this way this looks great. I've seen some hellish blueprints by some beginner UE4 users that would put this to shame any day. No sense of direction, too many things done in one class, all interconnected seemingly randomly. It can get rough.
1
u/[deleted] Mar 30 '21
lmao...
I can imagine how fun it was to drag these lines across the entire working field
1
u/StatisticianKk23 Apr 01 '21
holy sh*t tf did my eyes got affected by? it looks more like noodles
1
u/ferrango Well it's broken now, and nobody is here to fix it Apr 12 '21
I know I'm 15 days late, but this is beautiful.
Do you have it in a bigger resolution? It's not that my monitor can handle, I just want to know
1
u/illyay Dec 29 '22
Yeah blueprint is definitely spaghetti code. But I try to write it in ways that it’s not spaghetti. This is actually not necessarily even spaghetti code. It’s just they have one node that is a getter which they could’ve instead repeated instead of using one global one.
There are also many ways to do what are essentially gotos.
I figured out that using the sequence node is a way to do blueprint that is declarative like traditional code and avoid gotos and other spaghetti like flow.
0
u/[deleted] Mar 28 '21
[deleted] — view deleted comment