Created
June 22, 2020 18:03
-
-
Save softwarebygabe/6f634fdee25e0f18540f3a3b6792f246 to your computer and use it in GitHub Desktop.
This is usually the go-to pattern when the amount of object properties increases
This file contains hidden or 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
type Material = 'wood' | 'brick' | 'steel' | |
interface HouseOptions { | |
rooms: number | |
floors: number | |
material: Material | |
} | |
class House { | |
private rooms: number | |
private floors: number | |
private material: Material | |
constructor(options: HouseOptions) { | |
this.rooms = options.rooms | |
this.floors = options.floors | |
this.material = options.material | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
construction