Last active
September 13, 2018 17:26
-
-
Save chul-hyun/7abdedcad16af03f1e85ec05ff81f6ea to your computer and use it in GitHub Desktop.
캡슐화. 은닉성, getter setter를 쓰는것을 지양해야 하는 이유
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 ProceduralStopWatch { | |
public startTime; | |
public stopTime; | |
getElapsedTime = () => this.startMsTime - this.stopMsTime | |
} | |
// example | |
const stopWatch = new ProceduralStopWatch(); | |
stopWatch.startTime = Date.now(); | |
somthing(); | |
stopWatch.stopTime = Date.now(); | |
const elapsedTime = stopWatch.getElapsedTime(); | |
console.log(`result: ${elapsedTime}`); |
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 ProceduralStopWatch { | |
public startTime; | |
public stopTime; | |
public startNanoTime; | |
public stopNanoTime; | |
getElapsedTime = () => this.startMsTime - this.stopMsTime | |
getElapsedNanoTime = () => this.startNanoTime - this.stopNanoTime | |
} | |
// example | |
const stopWatch = new ProceduralStopWatch(); | |
stopWatch.startNanoTime = performance.now(); | |
somthing(); | |
stopWatch.stopNanoTime = performance.now(); | |
const elapsedNanoTime = stopWatch.getElapsedNanoTime(); | |
console.log(`result: ${elapsedNanoTime}`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment