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
I think objects should have 1 constructor that contains all parameters.
If needed we can then create static factory methods to instantiate from specific parameters. These static factory methods are short hands that enforce the implicit demands on constructor parameters.
In the example below, $b and $rf for example are mutually exclusive.
The constructor must check this in code, but for a user of the library createFromAB abstracts from that requirement (by hiding $rf)
For example:
class Ellipsoid extends {
public function __construct($a, $b = null, $rf = null, $code = null, $name = null) {
}
static public function createFromAB($a, $b) {
}
static public function createFromARF($a, $rf) {
}
}
The text was updated successfully, but these errors were encountered:
I think objects should have 1 constructor that contains all parameters.
If needed we can then create static factory methods to instantiate from specific parameters. These static factory methods are short hands that enforce the implicit demands on constructor parameters.
In the example below,
$b
and$rf
for example are mutually exclusive.The constructor must check this in code, but for a user of the library
createFromAB
abstracts from that requirement (by hiding$rf
)For example:
The text was updated successfully, but these errors were encountered: