File tree
Expand file treeCollapse file tree1 file changed
+19
-19
lines changed Expand file treeCollapse file tree1 file changed
+19
-19
lines changed Original file line number | Diff line number | Diff line change |
---|
@@ -1325,6 +1325,16 @@ example below, the implicit contract is that any Request module for an
|
1325 | 1325 |
|
1326 | 1326 | **Bad:**
|
1327 | 1327 | ```javascript
|
| 1328 | +class InventoryRequester { |
| 1329 | +constructor() { |
| 1330 | +this.REQ_METHODS = ['HTTP']; |
| 1331 | +} |
| 1332 | + |
| 1333 | +requestItem(item) { |
| 1334 | +// ... |
| 1335 | +} |
| 1336 | +} |
| 1337 | + |
1328 | 1338 | class InventoryTracker {
|
1329 | 1339 | constructor(items) {
|
1330 | 1340 | this.items = items;
|
@@ -1341,16 +1351,6 @@ class InventoryTracker {
|
1341 | 1351 | }
|
1342 | 1352 | }
|
1343 | 1353 |
|
1344 |
| -class InventoryRequester { |
1345 |
| -constructor() { |
1346 |
| -this.REQ_METHODS = ['HTTP']; |
1347 |
| -} |
1348 |
| - |
1349 |
| -requestItem(item) { |
1350 |
| -// ... |
1351 |
| -} |
1352 |
| -} |
1353 |
| - |
1354 | 1354 | const inventoryTracker = new InventoryTracker(['apples', 'bananas']);
|
1355 | 1355 | inventoryTracker.requestItems();
|
1356 | 1356 | ```
|
@@ -1600,6 +1600,15 @@ class EmployeeTaxData extends Employee {
|
1600 | 1600 |
|
1601 | 1601 | **Good**:
|
1602 | 1602 | ```javascript
|
| 1603 | +class EmployeeTaxData { |
| 1604 | +constructor(ssn, salary) { |
| 1605 | +this.ssn = ssn; |
| 1606 | +this.salary = salary; |
| 1607 | +} |
| 1608 | + |
| 1609 | +// ... |
| 1610 | +} |
| 1611 | + |
1603 | 1612 | class Employee {
|
1604 | 1613 | constructor(name, email) {
|
1605 | 1614 | this.name = name;
|
@@ -1612,15 +1621,6 @@ class Employee {
|
1612 | 1621 | }
|
1613 | 1622 | // ...
|
1614 | 1623 | }
|
1615 |
| - |
1616 |
| -class EmployeeTaxData { |
1617 |
| -constructor(ssn, salary) { |
1618 |
| -this.ssn = ssn; |
1619 |
| -this.salary = salary; |
1620 |
| -} |
1621 |
| - |
1622 |
| -// ... |
1623 |
| -} |
1624 | 1624 | ```
|
1625 | 1625 | **[⬆ back to top](#table-of-contents)**
|
1626 | 1626 |
|
|
You can’t perform that action at this time.
0 commit comments