Skip to content

Instantly share code, notes, and snippets.

View IvsonEmidio's full-sized avatar
🎵
Now the oceans have drained out, can I come up for air?

IvsonEmidio

🎵
Now the oceans have drained out, can I come up for air?
View GitHub Profile
@IvsonEmidio
IvsonEmidio / solid-ocp-violation-two.ts
Created May 1, 2022 23:29
SOLID - OCP - VIOLATION - EXAMPLE 2
class clients {
public function sendEmail (emailType: string){
if (emailType === 'html'){
let email = parseHtml(this.email);
} else if (emailType === 'plainText'){
let email = parsePlainText(this.email);
} else if (emailType === 'numeric') {
let email = parseNumeric(this.email);
}
@IvsonEmidio
IvsonEmidio / solid-ocp-correct.ts
Last active May 1, 2022 22:42
SOLID - OCP - CORRECT
import ICar from "./ICar";
class Diablo implements ICar {
readonly brand = "Lamborghini";
readonly color = "black";
public getMarketPrice(): Promise<number> {
return new Promise((resolve, reject) => {
let result = 200;
@IvsonEmidio
IvsonEmidio / solid-ocp-interface.ts
Created May 1, 2022 22:39
SOLID - OCP - Interface
export default interface ICar {
readonly brand: string;
readonly color: string;
getMarketPrice(): Promise<number>;
}
@IvsonEmidio
IvsonEmidio / solid-ocp-violation.ts
Created May 1, 2022 22:11
SOLID - OCP - VIOLATION
//First generic class
class Diablo {
private readonly brand = "Lamborghini";
private readonly color = "black";
}
//Second generic class
class Soul {
readonly brand = "Kia";
readonly color = "Red";