반응형 타입스크립트3 타입스크립트)제너릭(Generics) class ArrayOfNumbers { constructor(public collection: number[]) {} get(index: number): number { return this.collection[index]; } } class ArrayOfStrings { constructor(public collection: string[]) {} get(index: number): string { return this.collection[index]; } } //Generic을 적용함 class ArrayOfAnything { constructor(public collection: T[]) {} get(index: number): T { return this.collection[index]; } }.. 2023. 10. 9. 싱글톤 패턴(Singleton Pattern) 1. 싱글톤 패턴(Singleton pattern) 정리 싱글톤 패턴이란? 인스턴스를 단 1개만 만드는 패턴이다. 어플리케이션이 시작될 때 어떤 클래스가 최초 한번만 메모리를 할당하고(static) 그 메모리에 인스턴스를 만들어 사용하는 디자인 패턴이다. 예를들어 레지스트리 같은 설정 파일의 경우 객체가 여러개 생성되면 설정 값이 변경될 위험이 생길 수 있다. 인스턴스가 1개만 생성되는 특징을 가진 싱글턴 패턴을 이용하면, 하나의 인스턴스를 메모리에 등록해서 여러 쓰레드가 동시에 해당 인스턴스를 공유하여 사용할 수 있게끔 할 수 있기 때문에 요청이 많은 곳에서 사용하면 효율을 높일 수 있다. 주의해야 할 점은 싱글턴을 만들 때 동시성(Concurrency) 문제를 고려해서 설계해야 한다. 싱글톤 패턴의 .. 2023. 10. 1. 리액트) 테트리스 코딩(리액트 + toolkit + 타입스크립트 + styled components) 깃헙주소: https://github.com/Box-Cat/react-toolkit-tetris GitHub - Box-Cat/react-toolkit-tetris Contribute to Box-Cat/react-toolkit-tetris development by creating an account on GitHub. github.com 배포주소: https://647fa9cb2e3cc37e4ace08d0--classy-choux-d832e8.netlify.app/ REACT TOOLKIT TETRIS 647fa9cb2e3cc37e4ace08d0--classy-choux-d832e8.netlify.app *인터랙티브 웹을 적용해서, 핸드폰에서도 PC에서도 둘다 접속 가능합니다 2023. 9. 30. 이전 1 다음 반응형