Created
August 19, 2021 17:06
-
-
Save jeftarmascarenhas/7750f70786fa0a70dcbfea828d424f39 to your computer and use it in GitHub Desktop.
Refactoring Extract Method(Solution 1)
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
class LongMethod { | |
description: string = 'I need Refactoring' | |
printBanner(): void { | |
console.log('printBanner') | |
} | |
getOutMethod(): string { | |
return 'getOutMethod' | |
} | |
printOwing(): void { | |
this.printBanner() | |
// Print details | |
console.log(`description: ${this.description}`) | |
console.log(`amout: ${this.getOutMethod()}`) | |
} | |
} | |
const longMethodExample = new LongMethod() | |
console.log('Long Method \n') | |
longMethodExample.printOwing() | |
class ExtractMethod { | |
description: string = 'I was refactored, thanks god!' | |
printBanner(): void { | |
console.log('printBanner') | |
} | |
getOutMethod(): string { | |
return 'getOutMethod' | |
} | |
// Refactoring... | |
printOwing(): void { | |
this.printBanner() | |
this.printDetails() | |
} | |
printDetails(): void { | |
console.log(`description: ${this.description}`) | |
console.log(`amout: ${this.getOutMethod()}`) | |
} | |
} | |
const extractMethodExample = new ExtractMethod() | |
console.log('Extract Method \n') | |
extractMethodExample.printOwing() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment