Part of creating good code comes from how you choose to organize and format it.
This is what I like to do:
I have a main.lua
file + a scenes
directory with all my scenes inside. I use a lua file for each scene.
-> ProjectName/
- main.lua
-> scenes/
- mainMenu.lua
- highScores.lua
- game.lua
- pauseMenu.lua
- etc ...
main.lua
Inside main.lua I setup the game and all settings. After the setup I call the mainMenu scene to appear.
local composer = require("composer")
-- Setup game here:
composer.mySettings = "Some settings that can be accessed in any scene (highscores, volume settings, etc)"
composer.myVolume = 100
-- Use composer to go to our first game scene
composer.goToScene("scenes.mainMenu")
scenes/someScene.lua
Scenes respond to events in corona. These events are:
scene:create()
scene:show()
scene:hide()
scene:destroy()
Tips
I recommend you follow this tutorial
And use this template for all your scenes: