Proper way to access data in a custom table
If this question was about D7, you could start from what's suggested in the Developers Guide that comes with the Forena module (disclosure: I'm a co-maintainer of the D7 version). Here is a quote from its introduction:
Forena implements custom hooks to allow the report engine to be extended in many ways. Forena does use OOP methodologies, but also leverages the observer pattern so prevalent in Drupal.

There is then a common pattern that is used to extend Forena:

Implement a custom php class that lives in your module directory. You may extend any of the Forena classes, or write your own from scratch.
Implement the expected registration methods in your class (e.g. templates, formats).
In your module implement a hook (e.g. mymodule_forena_controls) that tells Forena the location of your class definition file.


These days, Forena has a dev version for D8 also, for which it's current status can be summarized like so (from it's release notes):

Basic rendering of reports and document types are complete, however the GUI version of the report writer has not yet been ported. Sufficed to say, this version can be used by Drupal 8 report writers who are comfortable writing .frx files and sql elements by hand.

Some more details to help you digest these release notes:

&quot;SQL elements&quot; refers to Data Blocks and the Data Sources they relate to, as explained in the Data Guide.
The &quot;.FRX files&quot; are the actual specifications of how you want you report to look like, as explained in the FRX Reporting Reference.
The &quot;GUI version of the report writer&quot; is what is explained in the WYSIWYG Reporting Guide.