
I'm an enthusiastic Chilean software engineer in New Zeland. I mostly focus on the back-end of the systems. This is my site, Señor Developer, where I share my knowledge and experience.
Search for a command to run...

I'm an enthusiastic Chilean software engineer in New Zeland. I mostly focus on the back-end of the systems. This is my site, Señor Developer, where I share my knowledge and experience.
In this series, I will show you the S.O.L.I.D principle. They consist of five object-oriented design principles which guide developers in writing clean, maintainable and efficient code.
S.O.L.I.D Principles Series
Quilla Frontend Kit turns recurring API, authentication, and server-state concerns into composable TypeScript packages.

Quilla Backend Kit provides the foundations for structured TypeScript services while leaving the application architecture in your hands.

Practical constraints for preserving the framework’s boundaries, dependency direction, and readability as a test suite grows.

A tool-agnostic approach to separating test intent from UI mechanics as an automation suite grows.

In this article, we will go through the entire process of set up Visual Studio Code for debugging “Deno” programs using “V8 Inspector Protocol”. Step-by-step, we will be learning how to configure VSCode to debug a Deno project. If you don’t know Deno...

Dependency Injection injects a class's dependencies from the outside, rather than instantiating them within the class. Because of this, classes are encouraged to have loose coupling, which facilitates changing dependencies or replacing them with alternative implementations.
Let's look at three classes of musicians: singers, drummers, and guitarists. In a band, every musician plays a certain part and needs the other musicians to play well together.

First, we are going to create the Musician interface:
interface IMusician {
play(): void;
}
Next, let's implement the classes for Guitarist, Drummer, and Singer:
class Guitarist implements IMusician {
play(): void {
console.log('Playing guitar');
}
}
class Drummer implements IMusician {
play(): void {
console.log('Playing drums');
}
}
class Singer implements IMusician {
play(): void {
console.log('Singing');
}
}
We will now create a class called Band which will require instances of Singer, Guitarist and Drummer as dependencies of the constructor method:
class Band {
constructor(singer: IMusician, guitarist: IMusician, drummer: IMusician) { }
performMusic(): void {
this.singer.play();
this.guitarist.play();
this.drummer.play();
}
}
Lastly, we will make instances of the Band, Singer, Guitarist and Drummer, and inject it as dependencies:
const band = new Band(
new Singer(),
new Guitarist(),
new Drummer()
);
band.performMusic();
In this example, the Band class implements the Dependency Injection principle by injecting Singer, Guitarist and Drummer instances as dependencies. This makes it simple to add new kinds of musicians (classic guitarist, jazz drummer or pop singer) or replace existing ones without changing the Band class.
You can get the source files from my GitHub repository.
I hope that this series was useful for you, thanks for your support.