-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
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) {
}
}
Metadata
Metadata
Assignees
Labels
No labels