Have you ever been bitten by a crazy dependency? Share your story.
Just wanted to say. Great lecture! Very insightful and explained well for us wanting to learn.
Actually, that happens to me quite a lot . You end spending most of the time fixing buggy dependent scripts than creating features. I used to search for a single script within a huge list of scripts in just one folder
i once spend an entire day having to change variable types because i changed the type my currency used when i was starting out as a dev. and because i had so many dependencies it affected my entire project, only to learn that it didn’t give me the effect i wanted and had to undo all the work. (what i learned, use source control, minimize dependencies)
I started using Unity a long time ago, there weren’t many tutorials back then so I primarily learned by watching Unity’s official tutorials which teach a lot of bad practices, all of my games used to have a Game Manager, but not like a simple game manager that manages states, no, no, no, a Static Game Manager with references to like other 7 to 9 managers, like UI Manager, and Sound Manager and so many managers, my code looked something similar to this
GameManager.gameManager.soundManager.audioSource.Play(GameManager.gameManager.soundManager.clips[1]);
That obviously created so many circular dependencies, it was a nightmare to debug, I obviously never finished any project back then.
I had that issue too, which added to my dependency nightmare.
When I worked in IT we had some monster dependency scenarios including when we went to Sharepoint, had 15 sharepoint sites all interdependent on each other (not my idea) and one day…some bright IT guy deleted one of the sites. It was my job to go through pages of documentation, and try to pull up a site that still sort of worked so I created a dummy site with fields, got a link to the second sharepoint site and laboriously went through the next 10 hours getting everything up. Not fun.
A lot of my major projects were like that. I could refactor them to thaw them out of the 9th level of hell into the 8th level, but it was hard to ascend much further.
I have had unity projects take so long to compile that I would start putting them in assemblies, but that would take a lot of refactoring or else every assembly depended on every other assembly and there would be no benefit.
Interfaces have been my main tool for reducing dependency (or sweeping it under an interface rug, which doesn’t hurt compilation time as much). Though I know it would be better to have a more fundamental reduction in dependency.
I’m always having trouble where I make a minor change and suddenly something completely unrelated breaks. It’s like straightening a picture in a house and the roof collapses.
I’m trying to do better now but it’s a struggle. See, I was mostly a self-taught programmer, a pro who got paid for it, yes, but still self-taught and other programmers would look at my code and say, “what idiotic software engineering teacher taught you that?” uh, teacher? I took a small number of computer science/programming classes in college to supplement my math major, but I learned to program on the Vic 20 and most of my added knowledge was through just doing it.
Assemblies are, on the other hand, an excellent way to enforce dependency inversion. If you actually have to expressly go in and manually link an assembly to another assembly, you’re going to take more time asking “why” than if you just add using ThisClass; I do find, though, that they’re most effective when I START with assemblies, rather than refactoring them in.