I’ve been making my first app for a few months and at this point it pretty much works, but the thought of adding to it seems like a nightmare. After watching some vids I’ve learned I programmed in the procedural style, and a lot of the spaghetti-ness of the code could potentially be solved by learning OOP. Of course some of that could probably be solved by better coding practices period, nonetheless, I’ve been exploring OOP and the logic really speaks to me. So I decided to make some classes/objects in Solar2d and I have a couple questions, not specific code questions, but more big picture things that I’m struggling with.
My biggest gap in knowledge, is how are objects supposed to communicate with one another? I’ve read about getting and setting, but I’m still missing a piece. It’s my understanding that objects are supposed to be modular, so perhaps I’m taking it too far, but is it wrong to build in methods that directly reference other objects and their methods? Or is the logic supposed to happen outside of that, where outside of the object I ‘get’ some info from one object and then pass it to another object to ‘set’? Maybe without the specifics of what I’m making these questions are too vague, I can give examples of how it relates to my app if necessary.
Also, I’m struggling with the idea of classes regarding display objects. If I make a class out of say, a rectangle, should that rectangle be visible? This may sound silly, but I read that the class is supposed to be a template in a sense, and the instances are the real thing. Does this mean I should leave the display part out and just include the methods, and then create the rectangle during instantiation?
I’ve done searches in the forum, and I’ve found some resources, but a lot of them are broken links that don’t work anymore, and a lot of them are getting started type posts, and many are ‘here is how you do OOP in Lua so now you can apply all the OOP stuff you already fully understand’. If you have any references, even in a different language, that would be helpful, or just comments to help me gain some understanding. Thanks!