Create a installer script for your component (com_your_component_name/script.php) and add the following code:
defined('_JEXEC') or die;
The installer script file allows you to run code when your component is installed, uninstalled, ...
For the purpose you are describing, your best bet is to create your own Joomla custom library. It's a type of Joomla extension alongside with plugins, modules and components, allowing you to put your custom common code. There is not much examples in Joomla documentation but Roberto Segura (phproberto) made an awesome example of a custom library available on ...
To answer the question about what is core and what isn't when you look at the extensions under the Extensions->Manage->Manage menu look at the ID column on the far right and if the ID is less than 999(or only has three digits) then it is core, if it above 10000 then it is 3rd party.
If the site has been progressively migrated from early versions of Joomla ...
Any layout or view can be overridden in Joomla.
You can do this in your Joomla admin panel, by going to:
Extensions (top menu) >> Templates >> Templates >> Details and Files
Once there, go to the "Create Overrides" tab, and you will be able to select your component annd the view.
So let's say you create an override for com_content/archive. This will ...