1번 미션 완료 (Commits 에서 for PullRequest 클릭하시면 됩니다)#1
1번 미션 완료 (Commits 에서 for PullRequest 클릭하시면 됩니다)#1ca1af wants to merge 5 commits intoCODE-CLEANERS:DKfrom
Conversation
ca1af
left a comment
There was a problem hiding this comment.
추상화라는 키워드를 다시 한 번 생각해보면 좋겠다.
- 추상화는 불필요한 부분을 무시하는 것
- 구체적인 사물들 간의 공통점은 취하고 차이점은 버리는 일반화로 단순하게 만든다.
Line, Square, 앞으로 진행할 Triangle 까지의 공통점을 어떻게 취할 수 있을까?
이들간의 차이점은 무엇이 있을까? 어떻게하면 차이점을 버리고도 같은 기능을 유지하게 할 수 있을까?
- 일반화/특수화
- 공통점, 차이점을 어떤 방식으로 뽑아내고 제거할까?
- 공통점을 일반화하는 방식에 대한 고민이 필요할 것 같다.
- 특수화를 통해서 차이점을 부각시킬 수 있는데, 불필요한 특수화를 제거하고 꼭 필요한, 객체를 식별가능하게 하는 특수화만을 진행하면 어떨까?
| import java.util.stream.Collectors; | ||
| import java.util.stream.IntStream; | ||
|
|
||
| public class Dots { |
There was a problem hiding this comment.
Dots 클래스가 너무 많은 일을 하고있는 것은 아닐까? 상속을 활용할 순 없을까?
src/main/java/calculator/Square.java
Outdated
| @@ -0,0 +1,16 @@ | |||
| package calculator; | |||
|
|
|||
| public class Square { | |||
There was a problem hiding this comment.
Dots 클래스가 너무 비대해서, 상대적으로 해당 객체를 사용하는 측은 너무 빈약해진 것이 아닐까?
| validateLocations(x, y); | ||
| this.x = x; | ||
| this.y = y; |
src/main/java/calculator/Line.java
Outdated
| public Line(String input) { | ||
| validateInput(input); | ||
| String[] split = input.split(SPLIT_EXPRESSION); | ||
| try{ | ||
| this.firstDot = new Dot(split[0]); | ||
| this.secondDot = new Dot(split[1]); | ||
| } catch (Exception e){ | ||
| throw new IllegalArgumentException(); | ||
| } |
There was a problem hiding this comment.
입력을 스트링이 아닌 "-"가 구분된 Dot 리스트로 받아오면 더 깔끔하지 않을까요?!
There was a problem hiding this comment.
Line 클래스에는 Dot 이 두개,, Triangle 클래스라면 Dot 이 세개,,
Line 생성시에 입력을 스트링으로 받아서 분리를 처리하는 로직 위치가 적합한지 궁금해요
There was a problem hiding this comment.
좋은 생각인 것 같습니다.
스트링으로 받지 않고 List 혹은 Dots 불변컬렉션으로 받는 것이 더 자연스러워 보입니다.
책임의 관점에서도 다희님이 말씀하신 것이 좋아보입니다. validate 의 역할을 밖으로 빼는 것이 이 경우엔 적절해 보입니다.
src/test/java/DotTest.java
Outdated
| Dot dot = new Dot(1, 1); | ||
| assertThat(dot).isEqualTo(new Dot(1, 1)); |
There was a problem hiding this comment.
isSameAs : 메모리상 같은 객체를 가리키는지 비교 (주소 비교)
isEqualTo : 객체가 같은 값을 가지고 있는지 비교
궁금해서 찾아봤습니다
There was a problem hiding this comment.
너무 훌륭합니다 ㅎㅎ Equals & HashCode 매소드를 오버라이드 한 객체는 isEqaulTo 로 비교가 가능합니다.
src/main/java/calculator/Line.java
Outdated
| private final Dot firstDot; | ||
| private final Dot secondDot; |
There was a problem hiding this comment.
Dot 리스트를 정의할 수 있는데, firstDot 과 secondDot 을 분리해서 선언한 이유가 궁금해요
There was a problem hiding this comment.
처음 구현부분에서는 Dots 라는 컬렉션을 사용하지 않아서, 위와 같은 형태로 작업했습니다.
ca1af
left a comment
There was a problem hiding this comment.
Dot, Line, Triangle, Square 까지 전부 완료했습니다.
우선 러프하게 만들고, 리뷰 받은 후에 구조를 바꾸려고 생각중이었습니다 ㅎㅎ
| validateLocations(x, y); | ||
| this.x = x; | ||
| this.y = y; |
src/main/java/calculator/Line.java
Outdated
| private final Dot firstDot; | ||
| private final Dot secondDot; |
There was a problem hiding this comment.
처음 구현부분에서는 Dots 라는 컬렉션을 사용하지 않아서, 위와 같은 형태로 작업했습니다.
src/main/java/calculator/Line.java
Outdated
| public Line(String input) { | ||
| validateInput(input); | ||
| String[] split = input.split(SPLIT_EXPRESSION); | ||
| try{ | ||
| this.firstDot = new Dot(split[0]); | ||
| this.secondDot = new Dot(split[1]); | ||
| } catch (Exception e){ | ||
| throw new IllegalArgumentException(); | ||
| } |
There was a problem hiding this comment.
좋은 생각인 것 같습니다.
스트링으로 받지 않고 List 혹은 Dots 불변컬렉션으로 받는 것이 더 자연스러워 보입니다.
책임의 관점에서도 다희님이 말씀하신 것이 좋아보입니다. validate 의 역할을 밖으로 빼는 것이 이 경우엔 적절해 보입니다.
src/test/java/DotTest.java
Outdated
| Dot dot = new Dot(1, 1); | ||
| assertThat(dot).isEqualTo(new Dot(1, 1)); |
There was a problem hiding this comment.
너무 훌륭합니다 ㅎㅎ Equals & HashCode 매소드를 오버라이드 한 객체는 isEqaulTo 로 비교가 가능합니다.
No description provided.