#Having Trouble with my code overall architecture

6 messages · Page 1 of 1 (latest)

small ocean
#

I learned C# programming and I can pretty much program whatever I want, but I always feels like my code architecture sucks...

I always end up stuck because of previous Mistakes or because I have to redesign a big chunk of code

Do you have good practives or good learning material I could check to get better ?

If someone who like architecture have some time, I'd like to show an exemple of schema I did before coding to have advices

hard swan
# small ocean I learned C# programming and I can pretty much program whatever I want, but I al...

there are channels and resources for overall architecture, but in general you get better if you practice
things like solid principles, design patterns and such
but the thing is that you should only apply these if they actually solve an issue you are facing
recently i found this channel which seems pretty good
https://gameprogrammingpatterns.com/contents.html

some others channels with some relevant videos
https://www.youtube.com/@Unity3dCollege
https://www.youtube.com/@InfallibleCode/videos
https://www.youtube.com/@Tarodev

unity also started a series on patterns:
https://www.youtube.com/watch?v=attURV3JWKQ&list=PLX2vGYjWbI0TmDVbWNA56NbKKUgyUAQ9i
they even had a book somewhere

maybe it also works to check through existing (open source) repositories that have a good structure
you could however also research clearn code and code architecture for c# in general, not specific to unity

fleet garnet
pearl sonnet
#

Hi @small ocean . To create a good architecture, you need to know the technologies you're working with and also a lot of years of learning. That doesn't mean you can create a quite good architecture in your 1st try, but the most probable is you will miss a lot of things.
I have a lot of years of experience in software architecture and the best advice I can bring you is try to draw all your system and see the level of coupling between your parts. Keep special care in the way all your objects/services are going to access the data. Try not to put all your data in a global context.
If you want, we can comment your current architecture and go with more specific solutions.

atomic kettle
# small ocean I learned C# programming and I can pretty much program whatever I want, but I al...

So the very first piece you need is SOLID.
https://en.wikipedia.org/wiki/SOLID

It's the master piece you want to understand perfectly, as it will be your highway to refactoring and architecturing as you go.

Read extensively about that topic.

Unity has kind of its own architecture embedded (entity-component), you can add layers on top if it if you feel like it, but most often than not, you'll bloat your code and create fake problems, that you will try to solve with even more layers, creating even more fake problems.

So start SOLID, and build around that for your own game.

In software engineering, SOLID is a mnemonic acronym for five design principles intended to make object-oriented designs more understandable, flexible, and maintainable. The principles are a subset of many principles promoted by American software engineer and instructor Robert C. Martin, first introduced in his 2000 paper Design Principles and D...

#

After that it's more about small questions/problems here and there:

  • How do I sync my animations with my game logic?
  • How do I pass data to another scene?
  • How do I link those two systems that feel very far apart?

A lot of that can be answered through Unity knowledge more than architecturing in itself, and its best to think of all that as isolate problems with each their own bit of solution.