-
Notifications
You must be signed in to change notification settings - Fork 0
/
after_good.ts
53 lines (43 loc) · 981 Bytes
/
after_good.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* @module solid_crockford/4_interface_segragation/oop/after_good
*/
/*
* We defined 3 segregated interfaces
* that are designed to accomplish
* what matters the most for roles
* expected for each.
*/
interface IEmployee {
use_chopsticks(): void;
cook_chow_mein(): void;
}
interface IAccountant {
use_excel(): void;
}
interface IDeveloper {
use_visual_studio(): void;
}
/**
* Accountants will no longer need to
* deal with using Visual Studio Code.
*/
class Accountant implements IEmployee, IAccountant {
public use_chopsticks() {}
public cook_chow_mein() {}
public use_excel() {}
}
/**
* Developers will no longer need to
* deal with using Excel at work.
*/
class Developer implements IEmployee, IDeveloper {
public use_chopsticks() {}
public cook_chow_mein() {}
public use_visual_studio() {}
}
{
const accountant = new Accountant();
accountant.use_excel();
const developer = new Developer();
developer.use_visual_studio();
}