I’m struggling a lot to understand how to write proper code architecture in UE.
There are certain restrictions that straight up destroy everything I’ve learned about good coding practices. Namely USTRUCTs not supporting UFUNCTIONs, UObjects not supporting custom constructors, USTRUCTs not supporting dynamic delegates properly, and a few others.
Let me give you the last example I’ve encountered. I’m working on a system similar to GAS, so an ability/combat system for an RPG. I have a Component for it, let’s say it’s BattleComponent. Characters will need stats, so I create an FAttributeSet struct, which has declared FAttributes inside. Neat, sounds plausible, right?
For reasons not worth explaining, these Attributes need a reference to it’s Owner BattleComponent. The only non-horrible way I know to do this is by passing a reference in it’s constructor. Still neat, right? But then you realize you’ll obviously use these FAttributes in BP, and you need to call their functions in their. But SURPRISE! You can’t have UFUNCTIONs in there. So maybe we can make it into an instanced UObject instead… yes, that would fix the USTRUCT limitations. I have no idea if it’s reasonable to make so many Instanced UObjects, but let’s say I don’t have a problem with it. You then realize UObjects can’t have custom constructors. Phenomenal.
This is just an isolated example, but this has been my whole experience with UE C++ so far. It just seems to push me towards writing code like they did before OOP was a thing. All these problems are fixed if I were to just stop abstracting so much and dumping everything into a monolithic class. Whenever I do an abstraction that keeps the code architecture neat, I immediately get slapped in the face by UE. I look into the source code for reference on how they do things, and I see monolithic classes with multiple thousand lines of code. Maybe I come from too strong a SOLID principle background, but this is just completely unacceptable to me.
I honestly can’t even imagine how people write complex big games under this framework… but then again, they do, and then do really well, so the problem must be me. I’m very likely missing some functionality that really fixes these issues, and overall architectural vision that would work correctly under UE’s framework.
So please let me know how you guys handle these problems, how you work around them… or your overall philosophy when architecturing systems in UE. Tutorials and demo projects have been a huge disappointment, I can’t find any complex systems written by competent people to use as reference. Any help would be highly appreciated. Cheers.