How I Untangled My Spaghetti Code

  Рет қаралды 1,834

Jim Makes Games

Jim Makes Games

Күн бұрын

In which I describe how my code got into a mess, figuring out what needs to be fixed, and how I used better coding techniques to avoid getting into these tangled messes in the first place.
Fire All Weapons on Steam:
store.steampow...
Fire All Weapons on Itch.io
jimmakesgames....
jimmakesgames.com
Twitch: / jimplayssgames
Twitter: / jimmakesgames
Bluesky: bsky.app/profi...
Patreon: / jimmakesvideos
#GameDev #DevLog

Пікірлер: 25
@luckyknot
@luckyknot Ай бұрын
thanks for taking the effort to pull this cautionary tale for game devs out Jim!
@straybasilisk2689
@straybasilisk2689 Жыл бұрын
Congratulations on the de-spaghettification of your code! Commiserations on the loss of your corporeal body.
@TheRetu81
@TheRetu81 Жыл бұрын
If you de-spaghettify your code, is it now macaroni code?
@JimMakesGames
@JimMakesGames Жыл бұрын
Thank you! It was getting annoying anyway. No more backaches!
@sqaxomonophonen5998
@sqaxomonophonen5998 Жыл бұрын
It sounds to me like you're doing it right :) It can be frustrating when you have to rewrite code, but I've been programming since 1989 and it's still something I do frequently. The road to good code is paved with rewrites of bad code :) Also, I think it's good that you apply principles like "one responsibility" when needed instead of preventively, because it's rarely clear what the scope of "one" even is to begin with (one game? one tiny action?), and you can easily overapply the principle which may cause its own kind of bad pasta ("ravioli code"), but when you're facing a real problem, you have the luxury of seeing if it works. As for game logic architecture,.. it might sound a bit silly, but I think I'd try to gather inspiration from tabletop game manuals and cards. So the main rules (manual) should be easy to read, and probably not be separated into classes anymore than you would separate a manual into chapters/sections. Cards benefit from brevity/writability, even to the point of sacrificing readability a bit (it's ok you have to read a page or two of the manual to understand what the card does).
@paulsgcross
@paulsgcross Жыл бұрын
Very cool and insightful. I'm on a similar journey myself -- wishing you all the best on the journey that is software architecting. Something that might also reduce spaghettification is having a mediator component. Instead of grabbing refs to objects direction thru Unity's GetComponent/Service-Locator, you could instead only ever reference to this middle-man component and pass messages through it to other components.
@JimMakesGames
@JimMakesGames Жыл бұрын
Thank you! Yeah I've looked into the mediator pattern and I am sure it will be useful somewhere. That's basically having something in a higher mediate communication between two other layers right? So they don't need to refer to each other at all. It seems like a lot to set up, but I'm sure worth it for some use cases.
@vissenekku
@vissenekku Жыл бұрын
Yeeeah, right now that I've been just doing "practice projects" or experimental things, I've completely neglected the spaghetti. 😄 I've been thinking that if it ever starts to look like a real game, I'd just have to remake it from scratch. Otherwise it's just too much. It's hard to avoid when you go into a project without knowing what you're making.
@JimMakesGames
@JimMakesGames Жыл бұрын
Oh yeah for prototyping none of this matters. And for small projects too. Shitty Quest and The Day The Earth Got Mooned were entirely feasible without worrying about layering or software architecture. But Guildmaster could absolutely have benefited from it, which is part of why it took so long. I would recommend making a complete but very small game first, and then a slightly bigger one. Don't just to something too big too soon. Each game should be a stepping stone where you learn enough to make the next one easier.
@gaz-a-reno8891
@gaz-a-reno8891 Жыл бұрын
I’m not a game designer. But I find this fascinating stuff Jim. I’ve got lots of idea for games, but it’s just the business end of all this annoying coding nonsense that gets in the way! 😂. Congratulations on your “Breakthrough” though Jim! 👍. What was your old self doing?… 😤. Does this now make approaching making a game MUCH simpler now? Or just a LITTLE simpler?!… 🤔. Anyway. Good luck to you on finishing this project! 😊
@JimMakesGames
@JimMakesGames Жыл бұрын
Thank you! I'd say it makes it much more practical. It's never simple, but now it's at least doable. If you want to make a game and don't want to code, consider looking into engines that don't require coding and use visual scripting or some other approach.
@AlfredRusselWallace
@AlfredRusselWallace Жыл бұрын
omg I love the fish aliens
@JimMakesGames
@JimMakesGames Жыл бұрын
Thanks! They were created by Julia Minamata, creator of The Crimson Diamond, in glorious 16 Colour EGA!
@jamesbateson5054
@jamesbateson5054 7 ай бұрын
Hi. Can you explain what you've done to get that cool "debug mode" view of your card states in the scene view (at kzbin.info/www/bejne/joW0en6Vh9CZgZY )?
@JimMakesGames
@JimMakesGames 7 ай бұрын
So that's just a zoomed out scene view, which shows stuff that exists beyond the scope of the canvas. The boxes that are labelled Player Deck and so on are just transforms with layout groups that the cards are parented to. I basically just made the rest of the "gaming table" that this game would be played at, but kept the game view constricted.
@jamesbateson5054
@jamesbateson5054 7 ай бұрын
Ah. I see. Good idea.
@Garfield_Minecraft
@Garfield_Minecraft 6 ай бұрын
0:30 wait nerd? so random
@JimPlaysGames
@JimPlaysGames 6 ай бұрын
It's the angry video game nerd. Thought everyone knew him lol
@Dollyhandle
@Dollyhandle Ай бұрын
@dbd
@namcos
@namcos Жыл бұрын
So you got too close to the black hole of the OO paradigm that your code got spaghettified? Sounds legit! :P
@JimMakesGames
@JimMakesGames Жыл бұрын
Exactly!
@pacbilly
@pacbilly Жыл бұрын
Hehehehe, that book title!
@alvarohenrique1309
@alvarohenrique1309 4 ай бұрын
This video is so high quality and easy to follow, thank you man!
@JimMakesGames
@JimMakesGames 4 ай бұрын
Thanks! I'm glad you enjoyed it 😁
@LastofAvari
@LastofAvari Жыл бұрын
Mmm... Tasty code!
How Senior Programmers ACTUALLY Write Code
13:37
Thriving Technologist
Рет қаралды 1,5 МЛН
How People Reprogram Games...with a CONTROLLER
18:42
GlitchDoctor
Рет қаралды 222 М.
小丑妹妹插队被妈妈教训!#小丑#路飞#家庭#搞笑
00:12
家庭搞笑日记
Рет қаралды 37 МЛН
Incredible: Teacher builds airplane to teach kids behavior! #shorts
00:32
Fabiosa Stories
Рет қаралды 10 МЛН
What Makes DBD So Buggy?
7:22
Scott Jund
Рет қаралды 44 М.
1 Year of Developing My Game in Godot
19:19
Blargis
Рет қаралды 265 М.
Ranting about Unity's latest decision...
6:13
Jim Makes Games
Рет қаралды 816
Factorio teaches you software engineering, seriously.
21:27
Tony Zhu
Рет қаралды 1,7 МЛН
PROTOTYPING 1 GAME IN 3 ENGINES
12:28
Rockers Games
Рет қаралды 1,5 М.
Software Architecture in Unity
7:13
Jason Storey
Рет қаралды 118 М.
20 Advanced Coding Tips For Big Unity Projects
22:23
Tesseract
Рет қаралды 186 М.
Spaghetti Code - What is...
7:25
Eli the Computer Guy
Рет қаралды 9 М.
Writing a game the hard way - from scratch using C. #1
34:20
NCOT Technology
Рет қаралды 127 М.
Stop Trying To Write "Perfect" Code
11:58
The Coding Sloth
Рет қаралды 56 М.
小丑妹妹插队被妈妈教训!#小丑#路飞#家庭#搞笑
00:12
家庭搞笑日记
Рет қаралды 37 МЛН