When code is generated, factory classes are also created. For models that depict database entities, they are generated automatically. Since Magento discourages direct usage of Object Manager, feature records are created, retrieved, or changed using factory classes instead. Although they are not required, these classes can be manually defined if we want to define particular behavior.