How to Optimization magento1 & 2 default Products, Order, Customer, Wishlist etc.. collection query?
This post will help you for best coding standard, How to follow Magento standard.
Please download this PDF and understand the Magento flow and how it's work and learn.
Follow this thread also: https://magento.stackexchange.com/a/124077/3723
Note: PDF for Magento 1 but it will help you for Magento 2 as well.