You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Even as the original author of most of the classes in this package, I've often found myself annoyed at how they are named 😅 We could easily improve this using class aliases.
The proposal that I outline below stems from this viewpoint: the names should reflect what the services are. For instance:
[
// message IS a value'message' => newValue('Hello'),
// greeting IS an alias'greeting' => newAlias('message'),
// username IS a global var'username' => newGlobalVar('username'),
// BUT ...// logger is ... a constructor??'logger' => newConstructor(Logger::class),
// alert_text is a ... string service??'alert_text' => newStringService("{0}, {1}!", [
'message',
'username',
]),
// render_fn is a funky what??'render_fn' => newFuncService(['message'], function (string$message) {
return$message;
}),
]
It would be great if all the classes had more sensible names that better outlined what the services are, rather than what the service definitions are.
I've prepared a list of which classes I think could use a better name, along with my proposed alias names:
Current name
New Alias name
Constructor
Instance
FuncService
Callback
StringService
TemplatedString
These proposed names will help to make service definitions look more natural and declarative.
[
// logger IS an instance'logger' => newInstance(Logger::class),
// alert_text IS a templated string'alert_text' => newTemplatedString("{0}, {1}!", [
'message',
'username',
]),
// render_fn IS a callback'render_fn' => newCallback(['message'], function (string$message) {
return$message;
}),
]
While we're at it, we could also alias the ArrayExtension class to ArrayPushExtension, in preparation for the new ArrayMergeExtension to create a clearer distinction between the two.
Thoughts?
The text was updated successfully, but these errors were encountered:
Even as the original author of most of the classes in this package, I've often found myself annoyed at how they are named 😅 We could easily improve this using class aliases.
The proposal that I outline below stems from this viewpoint: the names should reflect what the services are. For instance:
It would be great if all the classes had more sensible names that better outlined what the services are, rather than what the service definitions are.
I've prepared a list of which classes I think could use a better name, along with my proposed alias names:
These proposed names will help to make service definitions look more natural and declarative.
While we're at it, we could also alias the
ArrayExtension
class toArrayPushExtension
, in preparation for the newArrayMergeExtension
to create a clearer distinction between the two.Thoughts?
The text was updated successfully, but these errors were encountered: