|
|
|
|
|
by austincheney
3045 days ago
|
|
> export default class extends Controller { I know it is vanilla ES6, but at some point it starts looking more like Java than JavaScript. The boilerplate necessary to convey a simple instruction is directly proportional to the averaged speed of everything else (authorship, maintenance, execution, testing, frequency of reuse, and so forth). |
|
`export` -> exports the thing
`default` -> if you require from this module, this is the default
`class` -> class definition
`extends` -> speaks for itself
`Controller` class it's extending.
You could maybe rework it so you don't export it on the same line:
```
class Foo extends Controller {}
export default Foo
```
The parallel I see here to Java is the object orientation - which is a fair criticism. There are probably ways to execute on this using other mechanisms other than inheritance. But then, sub-classing to me still feels better than assigning the prototype via direct assignment.