Skip to Content
실무로 통하는 클린 코드
book

실무로 통하는 클린 코드

by 막시밀리아노 콘티에리, 이태영
August 2024
Beginner to intermediate
488 pages
11h 1m
Korean
Hanbit Media, Inc.
Content preview from 실무로 통하는 클린 코드
284
실무로 통하는 클린 코드
15.4
실제 객체로
null
대체하기
문제
실제로 존재하는
null
객체를 만들어야 합니다.
해결
null
객체 패턴을 포함한 디자인 패턴을 남용하지 마세요. 전단사에서 실제
null
객체
를 찾아서 이러한 객체를 대신 생성하세요.
설명
null
객체 패턴 (
15
.
1
절 ‘
null
객체 생성하기’ 참조 )을 과용하면 빈 클래스가 생성되고
네임스페이스가 오염되며 (
18
.
4
절 ‘전역 클래스 제거하기’ 참조 ) 중복된 동작이 발생할 수 있습
니다.
null
객체를 생성할 때 실제 객체 클래스를 인스턴스화해 사용할 수 있습니다.
null
체 패턴은
null
if
에 대한 훌륭한 대안이며, 패턴의 구조는 계층을 생성하도록 유도합니다.
그러나 반드시 필수인 것은 아닙니다. 그 대신 실제 객체가
null
객체에 대해 다형성을 유지해
야 합니다. 상속이 다형성을 달성하는 유일한 방법은 아닙니다 (
14
.
4
절 ‘
switch
/
case
/
else
if
문 대체하기’ 참조 ). 간단한 해결책은 실제 객체가
null
객체처럼 작동하도록 만드는 것입니
다. [표
15
-
1
]에는 몇 가지 친숙한
null
객체가 있습니다.
15-1
익숙한
null
객체
클래스
null
객체
숫자
0
문자열
""
배열
[]
다음 예제는
NullAddress
를 생성합니다.
abstract class ...
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

데이터 과학을 위한 통계(2판)

데이터 과학을 위한 통계(2판)

이준용, 피터 브루스, 앤드루 브루스, 피터 게데크
클라우드 네이티브 애플리케이션 디자인 패턴

클라우드 네이티브 애플리케이션 디자인 패턴

카순 인드라시리, 스리스칸다라자 수호티얀
데이터 엔지니어를 위한 97가지 조언

데이터 엔지니어를 위한 97가지 조언

Tobias Macey, 임혜연(Lim Hye Yeon)

Publisher Resources

ISBN: 9791169212779