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
The requirement that classes have a default constructor with no arguments makes it difficult to enforce certain invariants in those classes.
For example, if it's a guarantee in your application that your "User" class will always have an attribute called "emailAddress" which is set, then it shouldn't be possible to construct a User without the email address. The constructor should look something like this:
class User {
String emailAddress;
User(this.emailAddress);
}
Yet in order to make use of this rpc library, the class must have a parameterless constructor, which allows one to incorrectly construct a User.
The text was updated successfully, but these errors were encountered:
The requirement that classes have a default constructor with no arguments makes it difficult to enforce certain invariants in those classes.
For example, if it's a guarantee in your application that your "User" class will always have an attribute called "emailAddress" which is set, then it shouldn't be possible to construct a User without the email address. The constructor should look something like this:
Yet in order to make use of this rpc library, the class must have a parameterless constructor, which allows one to incorrectly construct a User.
The text was updated successfully, but these errors were encountered: