Closed forikal-uk closed 6 years ago
Rename:
make()
To:
createDomainGSheetObject
and then introduce a Template method according to the Template Pattern.
I was heading towards the Template Pattern.
But, after getting to know the InventoryFactory class a bit more I have had a breakthrough in understanding and realise that it is probably better use an Interface rather than an abstraction.
This gives greater flexibility to the user-land developer. Abstract models tend to be painful because people like freedom to design models without abstracts directing their way.
I am not so familiar with Symfony best practice.
I am just going to put it into the Model folder and it will be separated out when the concrete model is separated from the library.
I wonder how Return Type Declarations relate to method Interfaces?
It seems the concrete implementation can specify a return type while the Interface method specifies no return type. So, it seems to work.
Also, the docs kind of support that (albeit when talking about abstract methods):
http://php.net/manual/en/functions.returning-values.php#functions.returning-values.type-declaration
Note:
When overriding a parent method, the child's method must match any return type declaration on the parent. If the parent doesn't define a return type, then the child method may do so.
Let's see what happens when we set strict in the bootstrap.
<?php
declare(strict_types=1);
Result: Even in strict mode you can implement an Interface's method and set a return type when the return type is not set on the Interface's method definition.
That's interesting to know.
Let's go through and replace mentions of the interface instead of the concrete Inventory factory, where possible.
Goal
[See title]
Why
[See title]
How