Getting rid of module-specific control logic I'm writing a module that can have some additional functionality if other modules such as Block or Menu are enabled, but I don't want to declare them as a dependency.

Currently I'm using if(module_exists($module)) { ... } to provide module-specific functionality within my custom module (in this case, defining a particular view if the module in question is present).

However I've heard that this is not the right way to provide module-specific features, and that instead I should use hooks and plugins. The only problem is that I don't really know what that means or how to get started converting my module to using those instead of if()s. 

How do I define a custom view that depends on another module without using an if()?

One of the things I am trying to do is to expose that module's SQL tables to Views if the module exists, and then define a custom view with those tables.
If you want to provide Views with your module, dependent on enabled modules, you can implement

hook_views_default_views


  This hook allows modules to provide their own views which can either
  be used as-is or as a "starter" for users to build from.
  
  This hook should be placed in MODULENAME.views_default.inc and it will
  be auto-loaded. MODULENAME.views_default.inc must be in the directory
  specified by the 'path' key returned by MODULENAME_views_api(), or the
  same directory as the .module file, if 'path' is unspecified.
  
  The $view->disabled boolean flag indicates whether the View should be
  enabled (FALSE) or disabled (TRUE) by default.


In that hook implementation, you can check if the relevant module is enabled with module_exists or function_exists when defining that View or component of the View and return the View definition(s) accordingly.