among many things
Since you are a staunch opposer of oop rite ? so I asked'
JS is multiparadigm, but yes
But OOP is not possible in js but ts
supported in ES2020 or smth. ES5 has weird syntax.
OOP is possible in both JS and TS, but required in neither
So how do you make dependency injection
you just do it?
Example?
class Foo { dep; constructor(dep) { this.dep = dep; } method() { return this.dep.otherMethod(); } }
ES5 also works: function Foo(dep) { this.dep = dep; } Foo.prototype.method = function method() { return this.dep.otherMethod(); };
So you write this boilerplate code w/o interfaces
You need oop for building a robust DI implementation, it isn't that simple
Dependency Injection is not the core feature of OOP
do you know if the html messages support syntax highlight
I'm also confused about exactly what you think is missing here? Just interface syntax?
/** * @typedef Hello * @prop {() => void} hello */ class Foo { /** @type {Hello} */ dep; constructor(dep) { this.dep = dep; } method() { return this.dep.hello(); } }
Yeah, but you miss the builder
Why would you need a builder?
class FooBuilder { static buildFoo(service) { return new Foo(service); } } happy?
To alter the type of object to implement
I think you misunderstood my question entirely
Why do you need a builder in order to do that?
New business rules
Easy of modify code
More code that provides no extra functionality is always harder to modify
okay this is for reference.
Обсуждают сегодня