You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
3기
아서
입니다!과거에 들었던 강의를 다시 보다가
디미터 법칙
에 대해 얘기를 나누는 순간에 멍~해져서 공부할 겸 찾아보게 되었습니다!잠깐!
디미터 법칙
이란?객체 간의 결합도를 낮추기 위해 객체는 "친구" 객체에만 메시지를 보내야 하며, 객체의 내부 구조에 대해 지나치게 많이 알지 않아야 한다는 원칙.
Ex. 디미터 법칙을 어긴 예시
UIScreen.main.bounds.size.width
=> 디미터 법칙에 맞게 수정한 예시
extension UIScreen {
var screenWidth: CGFloat {
return self.bounds.size.width
}
}
// 사용 예시
let screenWidth = UIScreen.main.screenWidth
관련 아티클
https://velog.io/@kanamycine/디미터-법칙-Law-of-Demeter
Beta Was this translation helpful? Give feedback.
All reactions