If not OOP, then what?

Having come to the Corona SDK from a Flash/ActionScript background, and lacking a CS degree, I’ve been struggling with trying to organize the code in my first project. I’ve read that Lua can be made to conform to OOP principles, but my attempts to do so have felt awkward and riddled with error messages I’m struggling to understand.

I know that there are other ways of organizing/structuring code, but I don’t know what they’re called (and subsequently don’t know how to research them) nor do I know which might be best for Lua/Corona.

Any thoughts on this would be much appreciated.

David [import]uid: 101812 topic_id: 18040 reply_id: 318040[/import]

Hi David,

Usually if you are new to Corona, the best way to get your feet wet is to start with the storyboard api, or director class and use their templates to organize your code. (http://blog.anscamobile.com/2011/11/introducing-the-storyboard-api/ or http://rauberlabs.blogspot.com/2011/08/director-14-books.html)

However, if you are dead set on using true OOP, there are a couple of libraries you can use (Ricardo Rauber’s Loader class or MiddleClass). These can be found on Ricardo Rauber’s website (where you get director class) and the corona code exchange.

Otherwise, there are methods that are somewhat OOP that are much more simple and easy to understand for the casual programmer. Those typically involve utilizing the (awesome) flexibility of tables and modular coding.
http://blog.anscamobile.com/2011/06/understanding-lua-tables-in-corona-sdk/
http://blog.anscamobile.com/2011/09/a-better-approach-to-external-modules/
http://blog.anscamobile.com/2011/09/tutorial-modular-classes-in-corona/

I think the third option is what most Corona users go for.

-Matt
W2MD [import]uid: 10211 topic_id: 18040 reply_id: 68976[/import]