Skip to content

Commit

Permalink
chapter 03: splitting interfaces in order to avoid to need to throw a…
Browse files Browse the repository at this point in the history
…n error or not make something if some user uses changeOwner in a class that not have implementation
  • Loading branch information
devcorpio committed Mar 31, 2019
1 parent f818d26 commit 1922cf0
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
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 chapter-03-the-liskov-substitution-principle/refactor/localFile.js
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;

0 comments on commit 1922cf0

Please sign in to comment.