concept argument in category design

This is an excerpt from Manning's book Object Design Style Guide.
Just like you can define constructor parameters, you can define method parameters. A caller then has to provide a specific value as an argument when calling the method. The method itself can use the value to determine what to do, it can pass it on to collaborating objects, or it can use it to change the value of a property.
What’s wrong with the following code? final Translator { private string userLanguage; public function __construct(string userLanguage) { this.userLanguage = userLanguage; } public function translate(string messageKey): string { // ... } }
- The userLanguage constructor argument should have a default value, in case there is no logged-in user.
- The current user’s language should be retrieved from a service, which should be injected as a constructor argument.
- userLanguage should be passed as an argument when calling translate().
- Passing in userLanguage as a constructor argument makes it harder for Translator to be reused.
When a client of a class provides an invalid constructor argument, the type checker will usually warn you, such as when the argument requires a Logger instance and the client provides a bool value. However, there are other types of arguments where only relying on the type system will be insufficient. For instance, in the following Alerting class, one of the constructor arguments should be an int, representing a configuration flag.