Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core mission complete #22

Open
wants to merge 1 commit into
base: 24SongHyunWoo-core
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion docs/spring-core.md
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
# 요기다 정리
# 요기다 정리

### ioc container 없이 di를 하는 불편함을 이해하려면..
express로 개발을 해보시면 됩니다?

### DI & SOLID의 단점
오버 엔지니어링을 주의해야한다 같은 뻔한 이야기보다는 사실 SOLID는 객체 지향을 위한 하나의 지침일 뿐이지
그 자체만으로 객체 지향적 설계를 만들어주지는 않는다는 점<br>
그래서 결국 객체지향에 대한 본질을 이해하고 현실세계를 도메인으로 표현하는 것부터 잘해야 함<br>
그리고 그 과정에서 객체간의 메세징(또는 협력)이 충분하고, 또 객체가 충분히 자율적인지 생각<br>
그렇게 생각하다보면 자율성을 위해 추상화를 하는구나 이해하게 되고 그걸 위해 프레임워크에서 이런 기능을 제공하는구나 생각하게 됨<br>
이로써 프레임워크와 SOLID에서 종속적인 생각을 벗어나야함<br>
즉, OOP를 위해서는 결국 문제를 이해하고 디자인하는데에 시간을 오래 써야한다는 것<br>

Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package nextstep.helloworld.core.di;
import org.springframework.stereotype.Service;

@Service
public class StationConstructorService {
private StationRepository stationRepository;
private final StationRepository stationRepository;

// 생성자 주입
public StationConstructorService(StationRepository stationRepository) {
this.stationRepository = stationRepository;
}
public String sayHi() {
return stationRepository.sayHi();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package nextstep.helloworld.core.di;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StationFieldService {
@Autowired // 필드 주입
private StationRepository stationRepository;

public String sayHi() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package nextstep.helloworld.core.di;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StationSetterService {
private StationRepository stationRepository;

@Autowired
public void setStationRepository(StationRepository stationRepository) {
this.stationRepository = stationRepository;
}
public String sayHi() {
return stationRepository.sayHi();
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/nextstep/helloworld/core/scan/LineDao.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package nextstep.helloworld.core.scan;
import org.springframework.stereotype.Repository;

@Repository
public class LineDao {
}
9 changes: 9 additions & 0 deletions src/main/java/nextstep/helloworld/core/scan/LineService.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
package nextstep.helloworld.core.scan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LineService {
private final LineDao lineDao;

@Autowired
public LineService(LineDao lineDao) {
this.lineDao = lineDao;
}
}