-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chapter 03: splitting interfaces in order to avoid to need to throw a…
…n error or not make something if some user uses changeOwner in a class that not have implementation
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
chapter-03-the-liskov-substitution-principle/refactor/dropboxFile.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* In order to improve the understanding of this code, | ||
* this file it is supposing to implement the interface FileWithOwnerInterface | ||
* | ||
* interface FileInterface { | ||
* function rename(name); | ||
* } | ||
* | ||
* | ||
* interface FileWithOwnerInterface extends FileInterface { | ||
* function rename(name); | ||
* } | ||
* | ||
* Quack Quack Quack 🦆 typing :D | ||
*/ | ||
|
||
function dropboxFile() { | ||
function rename(name) {} | ||
|
||
return { | ||
rename, | ||
}; | ||
} | ||
|
||
module.exports = dropboxFile; |
27 changes: 27 additions & 0 deletions
27
chapter-03-the-liskov-substitution-principle/refactor/localFile.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* In order to improve the understanding of this code, | ||
* this file it is supposing to implement the following interface: | ||
* | ||
* interface FileInterface { | ||
* function rename(name); | ||
* function changeOwner(user, group); | ||
* } | ||
* | ||
* | ||
* Quack Quack Quack 🦆 typing :D | ||
*/ | ||
|
||
function localFile() { | ||
function rename(name) {} | ||
|
||
function changeOwner(user, group) { | ||
//make something | ||
} | ||
|
||
return { | ||
rename, | ||
changeOwner, | ||
}; | ||
} | ||
|
||
module.exports = localFile; |