목록전체 글 (956)
넘치게 채우기
시스템에 들어가는 모든 소프트웨어를 직접 개발하는 경우는 드뭅니다. 패키지와 오픈 소스를 주로 이용하고, 때로는 사내 다른 팀이 제공하는 컴포넌트를 사용할 때가 있습니다. 우리는 어떤 식으로든 이 외부 코드를 우리 코드에 깔끔하게 통합시켜야만 합니다. 이 외부 코드를 내 코드에서 호출하는 부분을 경계(boundary)라고 합니다. 외부 코드 사용하기 인터페이스 제공자와 사용자 사이에는 특유의 긴장감이 존재합니다. 패키지 제공자나 프레임워크 제공자는 적용성을 최대한 넓히려고 애쓰지만, 사용자들은 자신의 요구에 맞는 인터페이스를 바랍니다. 예시로, java.util.Map을 살펴봅시다. Map은 수많은 기능을 제공하는 인터페이스인데, 여기에는 내용을 삭제하는 clear()라는 메서드도 있습니다. 이 말은, ..
https://leetcode.com/problems/text-justification/description/?envType=study-plan-v2&envId=top-interview-150 Text Justification - LeetCode Can you solve this real interview question? Text Justification - Given an array of strings words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justified. You should pack your words i lee..
https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string/description/?envType=study-plan-v2&envId=top-interview-150 Find the Index of the First Occurrence in a String - LeetCode Can you solve this real interview question? Find the Index of the First Occurrence in a String - Given two strings needle and haystack, return the index of the first occurrence of needle in haysta..
오류 처리는 프로그램에 반드시 필요한 요소입니다. 상당수의 코드 기반은 전적으로 오류 처리 코드에 좌우됩니다. 여기서 좌우된다는 표현은 코드 기반이 오류만 처리한다는 의미가 아니라, 여기저기 흩어진 오류 처리 코드 때문에 실제 코드가 하는 일을 파악하기가 거의 불가능하다는 뜻입니다. 오류 처리로 인해 프로그램 논리를 이해하기 어려워진다면 깨끗한 코드가 불리기 어렵습니다. 이 장에서는 오류를 처리하는 기법과 고려 사항 몇 가지를 소개합니다. 오류 코드보다 예외를 사용하라 얼마 전까지만 해도 예외를 지원하지 않는 프로그래밍 언어가 많았습니다. public class DeviceController { ... public void sendShoutDown() { DeviceHandle handle = getHa..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/tP0j7/btsp7TIsh9N/EFx3kC0bno7kcB23At6plK/img.png)
https://leetcode.com/problems/zigzag-conversion/description/?envType=study-plan-v2&envId=top-interview-150 Zigzag Conversion - LeetCode Can you solve this real interview question? Zigzag Conversion - The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I leetc..
변수를 비공개로 정의하는 이유는 남들이 변수에 의존하지 않게 만들기 위해서입니다. 그렇다면 어째서 get 함수와 set함수는 공개해서 외부에 노출할까요? 객체와 자료 구조 객체는 추상화 뒤로 자료를 숨긴 채 자료를 다루는 함수만 공개합니다. 자료 구조는 자료를 그대로 공개 하며 별다른 함수는 제공하지 않습니다. 둘은 상반된 관계입니다. 자료 추상화 추상화는 개발자가 객체의 구현 세부 사항에 신경 쓰지 않고도 객체의 기능에 집중할 수 있도록 해주는 중요한 개념입니다. 코드의 복잡성을 줄이고 가독성을 높이는 데 중요한 역할을 합니다. 데이터 추상화를 사용하면, 객체의 실제 구현 내용을 숨기고 사용자에게 필요한 기능만을 제공하는 인터페이스를 제공할 수 있습니다. 이를 통해, 객체의 내부 구현이 변경되더라도 사..
https://leetcode.com/problems/word-break/description/ Word Break - LeetCode Can you solve this real interview question? Word Break - Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words. Note that the same word in the dictionary may leetcode.com 문제 유형 : 동적계획법, 문자열처리 문제 난이도 : Medium 문제 Given a stri..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bBczff/btspXlrB4x1/ZpPbw3onrbAyukIO7gXqtK/img.png)
프로그래머라면 형식을 깔끔하게 맞춰 코드를 짜야 합니다. 코드 형식을 맞추기 위해 간단한 규칙을 정하고 그 규칙을 따라야 합니다. 필요하다면 규칙을 자동으로 적용하는 도구를 활용할 수 있습니다. 형식을 맞추는 목적 오늘 구현한 기능이 다음 버전에서 바뀔 확률은 매우 큽니다. 오늘 구현한 코드의 가독성은 앞으로 바뀔 코드의 품질에 지대한 영향을 미칩니다. 오랜 시간이 지나 원래 코드의 흔적을 찾기 어려울 정도로 코드가 바뀌어도 맨 처음 잡아놓은 구현 스타일과 가독성은 앞으로의 유지보수에 영향을 끼칩니다. 적절한 행 길이를 유지하라 자바에서 파일 크기는 클래스 크기와 밀접합니다. 위 사진은 각각 JUnit, FitNesse, testNG, TAM, JDepend, Ant, Tomcat 프로젝트를 조사한 결과..
https://leetcode.com/problems/reverse-words-in-a-string/description/?envType=study-plan-v2&envId=top-interview-150 Reverse Words in a String - LeetCode Can you solve this real interview question? Reverse Words in a String - Given an input string s, reverse the order of the words. A word is defined as a sequence of non-space characters. The words in s will be separated by at least one space. Retu..
https://leetcode.com/problems/longest-common-prefix/description/?envType=study-plan-v2&envId=top-interview-150 Longest Common Prefix - LeetCode Can you solve this real interview question? Longest Common Prefix - Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1: Input: strs = ["flower","flow" ..