전체 글
-
일급 컬렉션☕️ java 2023. 10. 24. 02:56
🧑🏻💻 이동욱님의 글을 보고 공부용으로 정리했습니다. ⭐ 일급 컬렉션 Collection을 Wrapping 하면서, 그 외 다른 멤버 변수가 없는 상태를 일급 컬렉션이라 한다. Map map = new HashMap(); map.put("1", "A"); map.put("2", "B"); map.put("3", "C"); public class GameRanking { private Map ranks; public GameRanking(Map ranks) { this.ranks = ranks; } } 🌟 Wrapping의 이점 비지니스에 종속적인 자료구조 Collection의 불변성 보장 상태와 행위를 한 곳에서 관리 이름이 있는 컬렉션 1️⃣ 비지니스에 종속적인 자료구조 📖 숫자 야구의 2가지 조건 ..
-
🧪 JMH (Java Microbenchmark Harness)☕️ java 2023. 10. 23. 13:49
자바에서 제공하는 Random 함수에 대해 공부하는 과정에서 java.util.Random 과 java.util.concurrent.ThreadLocalRandom 의 성능을 비교해보고자 JMH라는 개념을 도입하고자 공부를 하게 되었다. ⭐ JMH 📍 JMH(Java Microbenchmark Harness)는 openjdk에서 만든 라이브러리이다. - JVM 상에서 실행되는 코드의 성능을 측정하기 위한 벤치마크 도구이다. 📍 성능 측정 코드 실행 시간 메모리 사용량 GC 활동 등등 ⇒ 측정하고 수행하여 실행 결과에 대한 통계를 제공한다. 📖 벤치마크 (Benchmark) 컴퓨터 시스템, 소프트웨어, 하드웨어 등의 성능을 측정하고 비교하기 위해 사용되는 표준화된 기준이나 테스트 🔍 Annotation 1..
-
🆚 Random 함수 비교☕️ java 2023. 10. 23. 12:36
숫자야구 프로그램을 만들면서 Java에서 제공하는 Random 함수들이 어떤 것들이 있는지 궁금하고 어떤 것을 사용해야할지 궁금했다. 1️⃣ java.util.Random 💡 java.util 패키지에 있는 Random 클래스를 사용하는 방법 - 인스턴스를 생성해서 사용 🖥️ 사용 2가지 객체 생성 방법 기본 생성자를 사용하는 방법 long 타입의 시드를 인자로 받는 생성자를 사용하는 방법 // 기본 생성자 Random random = new Random(); // long 타입의 시드를 인자로 받는 생성자 Random random = new Random(10); // 난수 범위 지정 int randomNumber = random.nextInt(max - min) + min; ⚠️ 주의할 점 long 타..
-
🍀 MongoDB - QueryDsl with Spring🌱 spring 2023. 5. 30. 14:44
프로젝트를 진행하는 도중 여러 조건을 통해 mongoDB에 있는 데이터를 조회하는 기능이 필요했다. 이에 따라 복잡한 쿼리를 쉽게 작성하기 위해 QueryDsl을 적용해보고자 했다. 📌 QueryDSL 💡 QueryDSL은 정적 타입을 이용해 SQL과 같은 쿼리를 생성할 수 있도록 해주는 오픈소스 프레임워크 JPQL을 Java 코드로 작성할 수 있도록 하는 라이브러리 🧑💻 Query DSL 설정 📖 build.gradle plugins { id "com.ewerk.gradle.plugins.querydsl" version '1.0.10' } ... dependencies { ... implementation group: 'com.querydsl', name: 'querydsl-mongodb', vers..
-
⚠️ WebFlux Error 처리🌱 spring/🍀 webflux 2023. 5. 1. 13:39
📌 Functional Level 💡 Error Handling 1. onErrorReturn Reactive Stream에서 Error가 발생했을 경우 정해진 Fallback value를 리턴 public final Flux onErrorReturn(T fallbackValue); public final Flux onErrorReturn(Class type, T fallbackValue); public final Flux onErrorReturn(Predicate
-
🐱 Tomcat🌱 spring 2023. 3. 12. 01:41
🐱 Tomcat 스프링 부트에서는 기본적으로 내장 서버로 톰캣을 사용한다. 📖 내장 서버(Embedded server)를 사용하는 이유 애플리케이션을 더 쉽게 개발하고 배포할 수 있도록 도와준다. 개발 및 테스트 용이 내장 서버를 사용하면 별도의 WAS를 설치하거나 구성할 필요가 없다. 따라서, 애플리케이션을 개발 및 테스트하는데 훨씬 용이 애플리케이션 개발 과정에서 코드를 수정하면 서버를 다시 시작해 변경 사항을 반영할 수 있다. 단일 패키지 배포 내장 서버를 사용 시, 애플리케이션과 서버가 단일 패키지로 묶여 있어 애플리케이션을 쉽게 배포할 수 있다. 서버를 설치하거나 구성하는데 필요한 복잡성이 줄어들고 배포 프로세스가 간소화된다. 높은 이식성 내장 서버를 사용하면 애플리케이션을 다른 환경으로 이식하..
-
DAO DTO / VO☕️ java 2023. 3. 10. 14:24
📌 DAO 💡 DAO (Data Access Object) - DB의 data에 접근하기 위한 객체로 직접 DB에 접근하여 데이터를 삽입, 삭제, 조회 등 조작할 수 있는 기능을 수행 실제로 DB에 접근하는 객체 등장 배경 애플리케이션에서 데이터베이스(MySQL, Oracle, … 등)에 접근하기 위해서는 각 벤더에서 제공하는 API를 통해서 접근하면 된다. ⚠️ 하지만, 이런 방법에는 문제가 존재 구현체와 로직에 강한 결합이 생긴다. DB로 MySQL를 사용하고 있었다고 가정했을 때, DB를 Oracle로 바꿔야 하는 요구사항이 생기면 MySQL의 API를 사용한 모든 로직을 Oracle의 API를 사용하도록 변경해야 한다 이는 변경에 자유롭지 못하는 문제를 가진다 - OCP 위반 레이어가 깨짐 표현계..
-
[Java] 실수 표현 - 고정소수점, 부동소수점☕️ java 2023. 3. 7. 13:40
📌 실수의 메모리 표현 컴퓨터 메모리는 2진수 체계를 기반으로 데이터를 저장한다. 실수 역시 2진수 메모리 비트로 표현해야 한다 → 정수에 비해 복잡 컴퓨터에서 실수를 표현하는 방식으로는 대표적으로 고정 소수점 방식, 부동 소수점 방식으로 나눌 수 있다. 🔍 고정 소수점 방식 💡 고정 소수점 방식 (Fixed-Point Number Representation) 메모리를 정수부와 소수부로 고정으로 나누고 지정하여 처리하는 방식 부호 비트 - 양수 / 음수를 표현하기 위한 비트 0 : 양수 1 : 음수 예시 5.625 = 4 + 1 + 0.5 + 0.125 = 2^2 + 2^0 + 2^{-1} + 2^{-3} = 101.101(2) 이진수 실수 계산 결괏값을 각각 정수부, 소수부 메모리 비트에 넣는다. 장 ..