Skip to content

1번 미션 완료 (Commits 에서 for PullRequest 클릭하시면 됩니다)#1

Open
ca1af wants to merge 5 commits intoCODE-CLEANERS:DKfrom
ca1af:DK
Open

1번 미션 완료 (Commits 에서 for PullRequest 클릭하시면 됩니다)#1
ca1af wants to merge 5 commits intoCODE-CLEANERS:DKfrom
ca1af:DK

Conversation

@ca1af
Copy link
Collaborator

@ca1af ca1af commented Oct 8, 2023

No description provided.

@ca1af ca1af changed the title 1번 미션 완료 1번 미션 완료 (Commits 에서 for PullRequest 클릭하시면 됩니다) Oct 8, 2023
Copy link
Collaborator Author

@ca1af ca1af left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추상화라는 키워드를 다시 한 번 생각해보면 좋겠다.

  1. 추상화는 불필요한 부분을 무시하는 것
  • 구체적인 사물들 간의 공통점은 취하고 차이점은 버리는 일반화로 단순하게 만든다.

Line, Square, 앞으로 진행할 Triangle 까지의 공통점을 어떻게 취할 수 있을까?
이들간의 차이점은 무엇이 있을까? 어떻게하면 차이점을 버리고도 같은 기능을 유지하게 할 수 있을까?

  1. 일반화/특수화
  • 공통점, 차이점을 어떤 방식으로 뽑아내고 제거할까?
  • 공통점을 일반화하는 방식에 대한 고민이 필요할 것 같다.
  • 특수화를 통해서 차이점을 부각시킬 수 있는데, 불필요한 특수화를 제거하고 꼭 필요한, 객체를 식별가능하게 하는 특수화만을 진행하면 어떨까?

import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Dots {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dots 클래스가 너무 많은 일을 하고있는 것은 아닐까? 상속을 활용할 순 없을까?

@@ -0,0 +1,16 @@
package calculator;

public class Square {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dots 클래스가 너무 비대해서, 상대적으로 해당 객체를 사용하는 측은 너무 빈약해진 것이 아닐까?

Copy link

@dhlee128 dhlee128 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

질문드립니다.
Dot, Line 을 구현하신게 맞을까요?

Comment on lines 24 to 26
validateLocations(x, y);
this.x = x;
this.y = y;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dot(x,y); 이면 코드 중복을 줄일 수 있지 않을까요?!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 맞습니다 ㅋㅋ 수정하겠습니다

Comment on lines 7 to 15
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();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

입력을 스트링이 아닌 "-"가 구분된 Dot 리스트로 받아오면 더 깔끔하지 않을까요?!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 클래스에는 Dot 이 두개,, Triangle 클래스라면 Dot 이 세개,,
Line 생성시에 입력을 스트링으로 받아서 분리를 처리하는 로직 위치가 적합한지 궁금해요

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋은 생각인 것 같습니다.

스트링으로 받지 않고 List 혹은 Dots 불변컬렉션으로 받는 것이 더 자연스러워 보입니다.

책임의 관점에서도 다희님이 말씀하신 것이 좋아보입니다. validate 의 역할을 밖으로 빼는 것이 이 경우엔 적절해 보입니다.

Comment on lines 17 to 18
Dot dot = new Dot(1, 1);
assertThat(dot).isEqualTo(new Dot(1, 1));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isSameAs : 메모리상 같은 객체를 가리키는지 비교 (주소 비교)
isEqualTo : 객체가 같은 값을 가지고 있는지 비교

궁금해서 찾아봤습니다

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

너무 훌륭합니다 ㅎㅎ Equals & HashCode 매소드를 오버라이드 한 객체는 isEqaulTo 로 비교가 가능합니다.

Comment on lines 4 to 5
private final Dot firstDot;
private final Dot secondDot;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dot 리스트를 정의할 수 있는데, firstDot 과 secondDot 을 분리해서 선언한 이유가 궁금해요

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

처음 구현부분에서는 Dots 라는 컬렉션을 사용하지 않아서, 위와 같은 형태로 작업했습니다.

Copy link
Collaborator Author

@ca1af ca1af left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dot, Line, Triangle, Square 까지 전부 완료했습니다.

우선 러프하게 만들고, 리뷰 받은 후에 구조를 바꾸려고 생각중이었습니다 ㅎㅎ

Comment on lines 24 to 26
validateLocations(x, y);
this.x = x;
this.y = y;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 맞습니다 ㅋㅋ 수정하겠습니다

Comment on lines 4 to 5
private final Dot firstDot;
private final Dot secondDot;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

처음 구현부분에서는 Dots 라는 컬렉션을 사용하지 않아서, 위와 같은 형태로 작업했습니다.

Comment on lines 7 to 15
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();
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋은 생각인 것 같습니다.

스트링으로 받지 않고 List 혹은 Dots 불변컬렉션으로 받는 것이 더 자연스러워 보입니다.

책임의 관점에서도 다희님이 말씀하신 것이 좋아보입니다. validate 의 역할을 밖으로 빼는 것이 이 경우엔 적절해 보입니다.

Comment on lines 17 to 18
Dot dot = new Dot(1, 1);
assertThat(dot).isEqualTo(new Dot(1, 1));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

너무 훌륭합니다 ㅎㅎ Equals & HashCode 매소드를 오버라이드 한 객체는 isEqaulTo 로 비교가 가능합니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants