I found that [lot][1] of [earlier][2] answers were using simple objectManager for class instantiation in Magento 2.

The results, lot of people are directly using/implementing those answers in their custom implementations.

>   we should not use the ObjectManager directly!


How can we avoid this practices, so users can be followed best coding standards.


  [1]: https://magento.stackexchange.com/questions/124878/how-can-i-check-whether-user-is-logged-in-or-not-in-magento-2-0/124879
  [2]: https://magento.stackexchange.com/questions/91897/how-to-check-if-customer-is-logged-in-or-not-in-magento-2