-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Function arguments (2 or fewer ideally) #111
Comments
@peter-gribanov It's a good point. I think that solution is to use private properties, setters and typed getters. E.g.
It means that if required properties(title, body, buttonText) are not set the TypeError exception will be thrown. But if optional property isn't set all will be ok and default value will be returned. |
@yuriyzinchenko Yes, by adding access methods we return control over the data types. |
This issue was about the problem of required properties, but i now looked more closely and realized that there was no problem. Sorry. |
Link to section.
A little strange.
In Bad example, the
createMenu()
function has 4 required dependencies ($title
,$body
,$buttonText
,$cancellable
).In Good example, the
createMenu()
function has only 1 required dependency (MenuConfig
).But
MenuConfig
does not have required dependencies.This means that we do not have guarantees that all the necessary dependencies will be in
createMenu()
function.This means that the Good example does not solve the problems in the Bad example.
The text was updated successfully, but these errors were encountered: