반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- controller
- 필터vs인터셉터
- n+1
- 세션이란
- BindingResult
- filter vs interceptor
- 세션vs쿠키
- Testcode
- 쿠키란
- abap value in field Data Class error
- 쿠키의 정의
- 유연한 컨트롤러1 - v5
- java.lang.AssertionError
- @Controller
- 김영한
- jpa
- spring MVC
- 필터의 정의
- MVC
- springSecurityFilterChain 오류
- SpringMVC
- 인터셉터의 정의
- Validation
- 세션의 정의
- application-properties
- 구글 보안 api 활용
- 401오류
- .orelseThrow
- spring
- optional
Archives
- Today
- Total
ABAP DUMP ERROR 24시
Abstract 과 interface 비교 본문
반응형
결론 :
Abstract 는 자식 클래스에게 공통으로 물려주고 싶은 역할. //DNA를 물려준다.
interface는 여러 잡다한 기능들을 사용할수 있게 해주는 역할.//신용카드로 사고픈거 사
Abstract 예시
Score |
Member_Score | Team_Score |
id name total avg str |
id name level address |
Abstract 사용시
public abstract class Score{
private String id;
private String name;
}
Score |
id name |
Member_Score | Team_Score |
total avg str |
level address |
처럼 묶을수 있다.
자식 table인 Member_Score 과 Team_Score는 id, name을 똑같이 가지고 있으니,
Score라는 추상 클래스에 담아두어 제공하면 다른 자식이 생기더라도 나눠줄수 있지!
interface 예시
@Transactional(readOnly = true)
@Repository
public interface TestRepositoy extends JpaRepository<Member, Long> {
}
다음과 같이 spring Data JPA 를 활용하여 findAll 혹은 findById 와 같은 기능을 활용하여 사용하고싶을 때는 interface를 사용하자.
반응형
'[WEB]Back-end > Java' 카테고리의 다른 글
ArrayList vs HashMap ,HashMap vs HashTable, 제네릭이란? (0) | 2022.02.10 |
---|---|
static, final, 필드, 메소드, 인스턴스 의미 정리 (0) | 2022.01.26 |
java 에서 this가 뭐야? (0) | 2022.01.20 |
int 와 Integer의 차이점 (0) | 2022.01.16 |
extends , interface 언제 써야 할까? (0) | 2022.01.10 |
Comments