If you're looking to stick with CodeIgniter's pattern for OOP (which is very standard) you would have your data methods in one or more models, your view files (for a control panel interface) in a views directory and your two module files (mcp.*
and mod.*
) would act as your two controllers.
As such, your directory structure might look something like this:
/mcp.addon.php (controller/logic)
/mod.addon.php (controller/logic)
/models/
/models/addon_model.php (data/model)
/views/
/views/index.php (a control panel view file)
/views/settings.php (view file)
When an add-on is large or needs some portable logic we tend to write libraries/classes outside of the mod
or mcp
files. You don't have to put everything in those controller files if you see a need to do otherwise.
As for an example, you can look at one of our add-ons, Dev Docs, to see code layout. Each add-on "type" (extension, module, etc) is a controller of its own. Then subdirectories contain other code as expected.
https://github.com/focuslabllc/dev_docs.ee_addon