분류 전체보기
-
5장 - 제네릭📕 book/이펙티브 자바 2022. 11. 1. 17:21
제네릭은 자바 5부터 사용할 수 있다. 제네릭을 지원하기 전에는 컬렉션에서 객체를 꺼낼 때마다 형변환을 해야 했다. 누군가 실수로 엉뚱한 타입의 객체를 넣어두면 런타임에 형변환 오류가 발생 ⇒ 제네릭을 사용해 컴파일 과정에서 차단하여 더 안전하고 명확한 프로그램을 만들자. 📌 로 타입은 사용하지 마라 클래스와 인터페이스 선언에 타입 매개변수(type parameter)가 쓰이면, 이를 제네릭 클래스 혹은 제네릭 인터페이스라고 한다. 제네릭 타입 (generic type) 제네릭 클래스와 제네릭 인터페이스를 통틀어 제네릭 타입이라 한다. 각각의 제네릭 타입은 일련의 매개변수화 타입 을 정의한다. ex) List 은 원소의 타입이 String인 리스트를 뜻하는 매개변수화 타입 String이 정규 타입 매개변..
-
4장 - 클래스와 인터페이스📕 book/이펙티브 자바 2022. 11. 1. 17:15
📌 클래스와 멤버의 접근 권한을 최소화하라 어설프게 설계된 컴포넌트, 잘 설계된 컴포넌트의 가장 큰 차이점 클래스 내부 데이터와 내부 구현 정보를 외부 컴포넌트로부터 얼마나 잘 숨겼느냐 잘 설계된 컴포넌트는 모든 내부 구현을 완벽히 숨겨, 구현과 API를 깔끔히 분리한다. 오직 API를 통해서만 다른 컴포넌트와 소통 서로의 내부 동작 방식에는 전혀 개의치 않는다. 정보 은닉, 캡슐화 장점 시스템 개발 속도를 높인다 시스템 관리 비용을 낮춘다 성능최적화에 도움을 준다. 소프트웨어 재사용성을 높인다 큰 시스템을 제작하는 난이도를 낮춘다. 접근 제어 메커니즘 자바는 정보 은닉을 위한 다양한 장치를 제공, 그중 하나가 접근 제어 메커니즘이다. 각 요소의 접근성은 그 요소가 선언된 위치와 접근 제한자로 정해진다...
-
Swagger 설정공부방 2022. 10. 27. 14:00
사용 이유 팀 프로젝트를 진행하면서 API 정보를 프론트 팀과 공유하기 위해 사용. 노션에 직접 URL과 파라미터, Response 등을 적어 주면서 API 정보를 공유했었는데 프로그램이 커지니 실수도 생기고 찾아보기도 힘들었다. 따라서, Swagger를 적용하여 자동으로 API 문서를 정리하도록 했다. ❓Swagger Swagger는 OAS(Open Api Specification)를 위한 오픈소스 프레임워크이다. 즉, API의 문서를 자동으로 정리해주는 것. Swagger를 통해서 Path, Request, Response, 조건 등을 한번에 알 수 있다. API 문서 자동화뿐 아니라 Swagger를 통해 파라미터를 넣어 테스트를 진행할 수 도 있다. Swagger를 사용하면 API 문서를 작성하는 ..
-
2장 - 아키텍처 개요📕 book/도메인 주도 개발 시작하기 2022. 10. 27. 00:54
📌 네 개의 영역 아키텍처를 설계할 때의 전형적인 네 가지 영역 표현 응용 도메인 인프라스트럭처 표현 영역 (UI 영역) 사용자의 요청을 받아 응용 영역에 전달하고 응용 영역의 처리 결과를 다시 사용자에게 보여주는 역할 사용자의 요청을 해석해서 응용 서비스에 전달 응용 서비스의 실행 결과를 사용자가 이해할 수 있는 형식으로 변환하여 응답 웹 애플리케이션의 표현영역은 HTTP 요청을 응용 영역이 필요로 하는 형식으로 변환해서 응용 영역에 전달하고 응용 영역의 응답을 HTTP 응답으로 변환하여 전송 응용 영역 시스템이 사용자에게 제공해야 할 기능을 구현 응용 영역은 기능을 구현하기 위해 도메인 영역의 도메인 모델을 사용한다. 사용자에게 제공할 기능을 도메인 모델을 이용해서 구현 응용 서비스는 로직을 직접 수..
-
3장 - 모든 객체의 공통 메서드📕 book/이펙티브 자바 2022. 10. 26. 21:19
💡 equals는 일반 규약을 지켜 재정의하라 꼭 필요한 경우가 아니면 equals는 재정의 하지 않은 것이 좋다. equals를 재정의하지 않아도 되는 경우 각 인스턴스가 본질적으로 고유 값을 표현하는 것이 아닌 동작하는 객체를 표현하는 클래스 - ex) Thread 값 클래스라도, 값이 같은 인스턴스가 둘 이상 만들어지지 않음을 보장하는 인스턴스 통제 클래스라면 재정의 하지 않아도 된다. 인스턴스 논리적 동치성을 검사할 일이 없을 때 상위 클래스에서 재정의한 equals가 하위 클래스에도 들어 맞을 때 ex) 대부분의 Set 구현체는 AbstractSet이 구현한 equals를 상속받아 사용 ex) List 구현체들은 AbstractList, Map 구현체들은 AbstractMap으로부터 상속받아 사..
-
2장 - 객체 생성과 파괴📕 book/이펙티브 자바 2022. 10. 25. 13:18
📌 생성자 대신 정적 팩터리 메서드를 고려하라 클라이언트는 클래스의 인스턴스를 얻는 전통적인 수단으로는 public 생성자이다. 클래스는 생성자와 별도로 정적 팩터리 메서드를 제공할 수 있다. 정적 팩터리 메서드 (static factory method) 해당 클래스의 인스턴스를 반환한다 (객체를 생성하는 메서드) ex) Optional의 of() : ‘new’ 키워드 대신 ‘of()’ 메서드를 이용해 객체를 만든다. 장점 1. 이름을 가질 수 있다. public class Hat { private String color; private int cost; private Hat(String color, int cost) { this.color= color; this.cost = cost; } public ..
-
Spring Scheduler🌱 spring 2022. 10. 24. 17:08
📌 Spring Scheduler @Scheduled Spring Scheduler는 @Scheduled 어노테이션을 명시해 사용할 수 있다. 보통 실행하고자 하는 메소드명 위에 명시 Scheduler가 정상 작동하기 위해서는 스프링 어플리케이션에서 Scheduling을 활성화 시켜주어야 한다. @EnableScheduling 어노테이션을 클래스 위에 명시해 활성화 시킨다. 사용하고자 하는 클래스 위에 명시할 수 도 있고 @SpringBootApplication 이 위치한 클래스 위에 명시해도 된다. 동작 Spring Scheduler는 동기적으로 스케줄러를 실행한다. 옵션 fixedRate fixedDelay Cron fixedRate 작업의 시작부터 시간을 카운트한다. @Scheduled(fixedR..
-
🤔 JWT공부방 2022. 10. 14. 20:40
⌨️ 로그인 방식 로그인을 처리하는 방법으로 생각할 수 있는 방법 유저에게 ID / Password를 받아 서버의 DB에 있는 데이터와 비교하는 방법 세션 방식 사용 Token 방식 사용 ID / Password 사용 방법 👎 로그인 유지가 되지 않는다. 페이지를 이동할 때마다 로그인을 다시 해야한다. ⇒ 로그인을 유지하면서 안전한 방법이 필요하다. 세션 방식 👊 - 서버 유지 세션 방식은 서버의 메모리, DB와 같은 서버의 자원들을 사용해 사용자의 정보를 유지시키는 방식이다. 토큰 방식보다 보안에 강하다 세션을 사용하는 경우 매 Request마다 서버는 쿠키를 받아, 세션 ID를 보고 해당 ID와 일치하는 유저를 찾아야한다. 요청이 있을 때마다 세션 DB를 조회해야 한다. ⇒ 유저가 증가할 수록 DB ..