Skip to content

Instantly share code, notes, and snippets.

View chul-hyun's full-sized avatar

Hyun chul-hyun

  • 대한민국(Korea)
View GitHub Profile
@chul-hyun
chul-hyun / Gear.6.ts
Created September 20, 2018 09:03
Chapter3
class Gear {
private _wheel: Wheel;
constructor(
readonly chainring: number,
readonly cog: number,
readonly rim: number,
readonly tire: number
) {}
@chul-hyun
chul-hyun / Gear.5.ts
Last active September 20, 2018 09:03
Chapter3
class Gear {
private _wheel: Wheel;
constructor(
readonly chainring: number,
readonly cog: number,
readonly rim: number,
readonly tire: number
) {}
@chul-hyun
chul-hyun / Gear.4.ts
Last active September 18, 2018 09:47
Chapter3
class Gear {
private _wheel: Wheel;
constructor(
readonly chainring: number,
readonly cog: number,
readonly rim: number,
readonly tire: number
) {}
@chul-hyun
chul-hyun / Gear.3.ts
Last active September 18, 2018 09:47
Chapter3
class Gear {
readonly wheel;
constructor(
readonly chainring: number,
readonly cog: number,
rim : number,
tire: number
) {
this.wheel = new Wheel(rim, tire);
@chul-hyun
chul-hyun / Gear.2.ts
Last active September 18, 2018 08:50
Chapter3
class Gear {
constructor(
readonly chainring: number,
readonly cog: number,
readonly wheel: { diameter: number }
) {}
get ratio() {
return this.chainring / this.cog;
}
@chul-hyun
chul-hyun / Gear.1.ts
Last active September 18, 2018 08:20
chapter 3
class Gear {
constructor(
readonly chainring: number,
readonly cog: number,
readonly rim: number,
readonly tire: number
) {}
get ratio() {
return this.chainring / this.cog;
@chul-hyun
chul-hyun / version1.ts
Last active September 13, 2018 17:26
캡슐화. 은닉성, getter setter를 쓰는것을 지양해야 하는 이유
class ProceduralStopWatch {
public startTime;
public stopTime;
getElapsedTime = () => this.startMsTime - this.stopMsTime
}
// example
const stopWatch = new ProceduralStopWatch();
@chul-hyun
chul-hyun / Gear1.ts
Last active September 10, 2018 14:14
유지보수가 쉬운 코드
class Gear {
constructor(readonly chainring: number, readonly cog: number) {}
ratio() {
return this.chainring / this.cog;
}
}
module.exports = {
'extends': 'airbnb',
// "parser": "typescript-eslint-parser",
// "parserOptions": {
// "ecmaVersion": 6,
// "sourceType": "module",
// "ecmaFeatures": {
// "modules": true,
// "jsx": true
// }
class Context{
- StrategyA strategyA
- StrategyB strategyB
}
package PackageStrategyA {
interface StrategyA{
+ excute()
}