Spring 실무 기초, 알고리즘, CS 특강, 어노테이션 특강

우정·2022년 12월 23일
0

[내일배움캠프] TIL

목록 보기
30/50

프로그래머스

피자 나눠 먹기(1)

  • Java
class Solution {
    public int solution(int n) {
        int answer = (n%7 == 0) ? n/7 : n/7 + 1;
        return answer;
    }
}
  • 올림
Math.ceil(double a)  // return type : double
  • 내림
Math.floor(double a)  // return type : double
  • 반올림
Math.round(double a)  // return type : long
Math.round(float a)  // return type : int
Math.floorDiv(int x, int y)  // return type : int
Math.floorDiv(long x, long y)  // return type : long
  • 나머지
Math.floorMod(int x, int y)  // return type : int
Math.floorMod(long x, long y)  // return type : long
  • 절대값
Math.abs(double a)  // return type : double
Math.abs(float a)  // return type : float
Math.abs(int a)  // return type : int
Math.abs(long a)  // return type : long
  • Python
import math

def solution(n):
    answer = math.ceil(n / 7)
    return answer
  • 올림(ceil)

    import math
    
    print(math.ceil(3.14))  # 4
  • 반올림(round)

    print(round(3.14)  # 3
    
    # 사사오입 원칙(반올림 할 자리의 수가 5이면 반올림 할 때 앞 자리 숫자가 짝수면 내림, 홀수면 올림을 함)
    print(round(3.5))  # 4
    print(round(4.5))  # 4
  • 내림(floor)

    import math
    
    print(math.floor(3.14))  # 3
  • 버림(trunc)

    import math
    
    print(math.floor(-1.23)) # -2
    print(math.trunc(-1.23)) # -1, 0에 가까운 정수 선택

Spring 실무 기초

Javascript 기초

  • 변수

    • 변수 선언 : let
  • 자료형

    // 문자 (홑,쌍따옴표 상관 없음)
    let name = 'sparta';
    let name = "camp";
    let num = 10;
    console.log(num + name); // 10sparta : 문자 + 숫자 하면 둘 모두를 문자로 묶음
    
    // boolean
    let age = 18;
    let adult = age > 20;
    console.log(adult);  // false
    
    // 리스트
    let fruits = ['사과', '딸기', '수박'];
    console.log(fruits[0]);  // 사과
    
    // 딕셔너리
    let course = {
      'name': '홍길동',
      'age': 18
    };
  • 반복문

    let fruits = ['사과', '딸기', '수박'];
    for (let i = 0; i < fruits.length; i++) {
    		  let fruit = fruits[i];
    		  console.log(fruit);
    }
  • 조건문

    let fruits = ['사과', '딸기', '수박'];
    for (let i = 0; i < fruits.length; i++) {
    		  let fruit = fruits[i];
    		  console.log(fruit == '수박');
    }
  • 함수

    function sample() {
    		  alert('얼럿!');
    }
  • 백틱

    let name = '내 이름';
    let text = `${name}님의 스프링 5주 완주를 축하합니다!`;
    console.log(text);  // 내 이름님의 스프링 5주 완주를 축하합니다!

CS특강

생성(Creational) 패턴

  • 생성
    • 객체 생성에 관련된 패턴
    • 구체적인 클래스를 지정하지 않고 관련성을 갖는 객체들의 집합을 생성하거나 서로 독립적인 객체들의 집합을 생성할 수 있는 인터페이스를 제공함

구조(Structural) 패턴

  • 구조
    • 클래스나 객체를 조합해 더 큰 구조를 만드는 패턴
    • 예를 들어 서로 다른 인터페이스를 지닌 2개의 객체를 묶어 단일 인터페이스를 제공하거나 객체들을 서로 묶어 새로운 기능을 제공하는 패턴

행위(Behavioral) 패턴

  • 행위
    • 객체나 클래스 사이의 알고리즘이나 책임 분배에 관련된 패턴
    • 한 객체가 혼자 수행할 수 없는 작업을 여러 개의 객체로 어떻게 분배하는지, 또 그렇게 하면서도 객체 사이의 결합도를 최소화하는 것에 중점을 둠

어노테이션 특강

Annotation

  • 종류
    • Built-in Annotation
    • Meta Annotation
    • custom Annotation
  • 목적
    • 클래스, 메서드, 변수가 포함된 프로그램 코드 자체에는 아무런 영향을 미치지 않으면서 중복 코드를 줄이고 싶을 때 사용
  • 용도
    • 컴파일러에게 코드 작성 문법 에러를 체크하도록 정보를 제공
    • 빌드 시 코드를 자동으로 생성할 수 있도록 정보를 제공
    • 실행시(런타임시)특정 기능을 실행하도록 정보를 제공

빈(Bean) VS 컴포넌트(Component)

  • 컴포넌트

Spring MVC 기본 어노테이션

  • @Controller
  • @Mapping
  • @Service, @Repository

0개의 댓글

관련 채용 정보