For many common tasks, Omeka S provides helpers for obtaining the necessary service. Thus, when you need to use the Omeka\Logger service, you need not get it via the $serviceLocator (indeed, often you cannot -- more on that below). Instead, within a controller you can simply do:

$this->logger()->warn('Something bad is happening.');

Factories

Among other things, factories are used to instantiate a class and inject other related data and classes into it. In Omeka S, this commonly means making a service available to address a special condition in which the service serves a special need.

Take, for example, the Omeka2Importer plugin. Its first job is to retrieve data from an existing Omeka Classic site. A client for interacting with Omeka Classic's API had already been developed to handle the tasks of requesting and processing data. That client just needed to be included into the Omeka S module to make it available. That happens by using a Factory to inject the Service into the Controller.

The constructor for Omeka2Importer\Controller\IndexController\IndexController then assigns the client to its corresponding property, and uses it as needed.

Another common Factory task is to inject needed services into Forms. For example, if you need the Zend\Event\EventManager to trigger an event or access to Site setting, you will need to create the Form via a Factory that injects it: