Skip to Content
자바스크립트 + 리액트 디자인 패턴
book

자바스크립트 + 리액트 디자인 패턴

by 애디 오스마니(Addy Osmani), 윤창식
August 2024
Beginner to intermediate
384 pages
7h 38m
Korean
Hanbit Media, Inc.
Content preview from 자바스크립트 + 리액트 디자인 패턴
95
Chapter 07_
자바스크립트 디자인 패턴
7.4.2
단점
노출 모듈 패턴의 단점은 비공개 함수를 참조하는 공개 함수를 수정할 수 없다는 것입니다.
이는 비공개 함수가 비공개 구현을 참조하기 때문에 발생하며, 수정을 해도 함수가 변경될
뿐 참조된 구현이 변경되는 것이 아니기 때문입니다.
비공개 변수를 참조하는 공개 객체 멤버 또한 수정이 불가능합니다.
따라서 노출 모듈 패턴으로 만들어진 모듈은 기존 모듈 패턴보다도 취약할 수 있으므로 사용
에 주의해야 합니다.
7.5
싱글톤 패턴
싱글톤
Singleton
패턴은 클래스의 인스턴스
instance
가 오직 하나만 존재하도록 제한하는 패턴입
니다. 이 패턴은 전역에서 접근 및 공유해야 하는 단 하나의 객체가 필요할 때 유용합니다.
싱글톤 패턴을 구현하려면 이미 존재하는 인스턴스가 없어야 합니다. 인스턴스가 이미 존재
할 경우에는 해당 인스턴스의 참조를 반환합니다.
싱글톤 패턴은 정적 클래스나 객체와는 다르게 초기화를 지연시킬 수 있습니다. 왜냐하면 초
기화 시점에 필요한 특정 정보가 유효하지 않을 수도 있기 때문입니다. 싱글톤 클래스의 인
스턴스가 이미 생성되었다는 사실을 모른다면 해당 인스턴스를 찾아 사용하기 어렵습니다.
이는 싱글톤이 객체나 ‘클래스’가 아닌 구조이기 때문입니다. 클로저 변수 자체가 클로저가
아니라 클로저를 제공하는 함수 스코프가 클로저를 뜻한다는 것과 비슷합니다.
ES2015
+에서는 자바스크립트 클래스의 전역 인스턴스를 단 한 번만 생성하는 싱글톤 패턴
을 구현할 수 있으며, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

실전 시계열 분석: 통계와 머신러닝을 활용한 예측 기법

실전 시계열 분석: 통계와 머신러닝을 활용한 예측 기법

박찬성, 에일린 닐슨
클라우드 엔지니어를 위한 97가지 조언

클라우드 엔지니어를 위한 97가지 조언

Emily Freeman, Nathen Harvey, 정기훈(Jung Ki Hun)

Publisher Resources

ISBN: 9791169212571