Organizing Code Properly

My code for my game is starting to get rather lengthy, i am brand new to programming and corona so i ask the question, how should i organize my code?

Can someone give a good list of how things should be placed, such as should all variables be named first, then objects, then eventlisteners, functions, etc… how should these all be placed? i think ive mostly just gotten lucky so i would love to learn the correct way of organizing my mess! =D thank you [import]uid: 19620 topic_id: 6691 reply_id: 306691[/import]

I recommend taking an object oriented approach. For example this is what I do:
http://developer.anscamobile.com/code/object-oriented-sample-game-framework [import]uid: 12108 topic_id: 6691 reply_id: 23461[/import]

Think about which functionality you need over and over, and outsource those bits into small functions. Once you have dozens of lines and indents, ask yourself: which part of this is a separate entity that could deserve its own space elsewhere? Furthermore, as JHocking said, think of objects with attributes… this will help you organize your code. My games are organized around a sprite object (type, subtype, phase etc.) which are organized by the app and have functionality like makeSound, collisionWith, listenToTouch etc. Good luck, usually the more you code the more you’ll find you’ll naturally understand how to refactor things and organize it! [import]uid: 10284 topic_id: 6691 reply_id: 23639[/import]

thanks for the tips guys i appreciate the information [import]uid: 19620 topic_id: 6691 reply_id: 23686[/import]