Skip to content

Conversation

@DongLee99
Copy link

No description provided.

Copy link
Contributor

@Livenow14 Livenow14 left a comment

Choose a reason for hiding this comment

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

조금 더 본인의 말로 풀어봐도 좋을듯

Comment on lines +54 to +57
_ 그래서 객체 지향은?_
자바를 생각하면서 객체 지향을 떠올리면 가장 먼저 떠오르는것은 클래스 이다. 비록 다른 사람의 글을 보면서 글을 적고 있지만 이 사람 처럼 수업 시간에 배웠던것 처럼 자바 => 클래스 가 공감이 된다. 우리 학교도 수업시간에 자바를 하면 클래스만 주구장창 배웠기 떄문이다.

코딩의 관점에서 본다면 클래스가 객체를 만들기위한 틀, 도구이기에 객체지향을 클래스 라고 착각할수가 있다. 객체지향의 주인공은 클래스가 아니라 객체 이다. 이 객체를 분류 하기 위한 것이 클래스 이다. 따라서 코드를 담는 클래스의 관점이 아닌 메시지를 주고 받는 객체의 관점으로 애플리케이션을 바라 보아야 한다.
Copy link
Contributor

Choose a reason for hiding this comment

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

goood

---

#### 책임
* 애플리케이션의 기능은 좀 더 작은 책임으로 분할되며 책임은 적절한 역할을 수행할수 있는 객체에 의해 수행된다. ( 객체 지향 설계 = > 적절한 객체에 적절한 책임을 할당함으로 부터 시작)
Copy link
Contributor

Choose a reason for hiding this comment

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

책임은 역할을 수행할 수 있는 객체에 의해 수행

객체가 먼저일까요, 책임이 먼저일까요?

* 관련된 객체에 대해 아는 것
* 자신이 유도하거나 계산할 수 있는 것에 대해 아는 것

(그냥 내 생각인데 이는 자바에서 코드를 짤때 메서드를 호출해 직접 상태를 변형 시키거나 다른 객체의 상태를 변형 시키는 것, 이때 변환 시킬 객체를 아는 것 등을 의미하는것 같다)
Copy link
Contributor

Choose a reason for hiding this comment

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

메서드를 호출한다라는 말이 입에 붙지않게 조심!
여기서의 말은 뭔가 다른객체의 상태를 알아야한다는 전제가 깔려있는 것 같아요.

저는 하는 것과 아는 것을 메소드의 개념으로 생각하는 것이 아닌, 하는 것(수신된 책임을 수행하는 것, 맡은 역할에서 해야할 행동) 아는 것 (어떠한 책임을 필요로 하는지 아는 것(관련된 객체에 대해 알아야함), 나의 상태에 대한 정보 )라는, 넓은 의미에서 생각했어요

* 책임과 메시지

* 위의 doing, knowing을 보면 자신의 상태를 변환 시키는것들도 있지만 다른 객체에 관여 하는것도 많다 이때 객체의 유일한 의사소통 수단인 메시지가 사용된다는 사실을 유추해 낼수 있다.
* 너무 추상적인 메시지는 의도가 변형될수있으므로 구체적이여한다.
Copy link
Contributor

Choose a reason for hiding this comment

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

예제가 있으면 조금더 좋을거같아요

* 역할은 관련성이 높은 책임의 집합으로

* 동시에 여려객체가 동일 역할을 수행 할수있다.
* 역할은 대체 가능성을 의미한다.
Copy link
Contributor

Choose a reason for hiding this comment

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

객체지향의 어떠한 성질 덕분에 이러한 가능성을 의미하게 되는 걸까요?

Comment on lines 140 to 143
#### 캡슐화
* 객체의 자율성을 보전하기 위해 구현을 외부로 부터 감추는 것
* 객체는 상태와 행위가 함께 캡슐화 되어 충분히 협력적이고 자율적인 존재가 된다.

Copy link
Contributor

Choose a reason for hiding this comment

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

조금더 본인의 말로 다듬어도 좋을듯

Comment on lines +166 to +169
```
위 코드 처럼 재할당이 가능하다. = str 이 처음에 "abc" 를 참조했는데 이 값이 "cba" 로 바뀌는 것이아니라 "cba"라는 새로운 객체가 생기고 그 객체를 str 이 재참조 하는것이다. 이때 "abc" 는 아무도 참조를 하고있지 않게 된다.

_그렇다면 계속 str에 재할당을 한다면 객체가 생성된채로 낭비가 된다는 것인데 이는 어떻게 처리하는게 옳은 방법일까?_
Copy link
Contributor

Choose a reason for hiding this comment

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

GC의 대상이 되는거죠!

Comment on lines +171 to +173
* String vs String Builder

* String Builder 는 String 과 다르게 mutable 하기 때문에 변경을 하더라고 새로운 객체를 만들지 않고 기존 할당된 값을 수정 한다. 즉 문자열 변경과 연산을 하는 경우 기존의 버퍼 크기를 늘리거나 줄이면서 유연한 동작이 가능하게 된다.
Copy link
Contributor

Choose a reason for hiding this comment

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

알고리즘 문제풀이 에서 String Builder가 빠른이유!

Copy link
Contributor

@Livenow14 Livenow14 left a comment

Choose a reason for hiding this comment

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

기초 피드백.
수업시간에 조금더 다뤄볼 것이 많음.

Comment on lines 279 to 295
```java
public class ArrayObject {

private final int[] array;

public ArrayObject(final int[] array) {
this.array = Arrays.copyOf(array,array.length);
}


public int[] getArray() {
return (array == null) ? null : array.clone();
}
}
```
* 배열의 경우 생성자에서 배열을 받아 copy해서 저장 했고 getter를 clone 으로 반환하게 하면 불변객체로 만들수있다. (배열을 그대로 참조 or 그대로 반환시 내부 값이 변경될수도있다.)
---
Copy link
Contributor

Choose a reason for hiding this comment

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

Collection.unmodified 라는 옵션도 살펴보실

Comment on lines 876 to 900
### (optional) java 13. switch 연산자
* switch 연산자

* 스위치 연산자라 하면 기존의 자바 문법의 switch 를 생각 할것이다.
* 기존의 스위치문은 break 를 걸지 않으면 자신이 속한 case 를 진행후 스위치 문을 탈출 하지 않고 다음 case 를 거치게 된다.
```java
switch (day) {
case Monday:
break;
case Friday:
case Sunday:
}
```
이를 막기위해서 java13 에서 부터는 화살표 연산자가 추가 되면서
```java
switch (day) {
case Monday -> numDay = 1:
case Friday -> numDay =2:
case Sunday -> numDay =3:
}
```
case 의 label 이 매칭이 되면 -> 이후 코드를 실행하고 switch문을 탈출하게 된다.

---

Copy link
Contributor

Choose a reason for hiding this comment

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

switch문 -> switch 연산자가 된것이 아닌,
swtich문 + switch 연산자가 된 것 입니다.
정리가 조금더 필요할듯!

@Livenow14
Copy link
Contributor

Livenow14 commented Jan 29, 2021

Caludator 클래스에
시작, 입력, 출력, 계산, 숫자 저장등의 책임을 다 지니고 잇네요.
위의 책임을 객체로 분리해봐요 (메소드의 분리보다 더 중요)

@Livenow14
Copy link
Contributor

그리고 쓰지않을 Hello.java이런 것들은 가독성에서 오히려 방해가 되니 삭제 바랍니다.

Copy link
Member

@PandaHun PandaHun left a comment

Choose a reason for hiding this comment

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

조금 더 설명이 필요한 코드라 생각이 필요할 것 같습니다 :)

@@ -0,0 +1,10 @@
public class Hello {
public static void main(String [] args){
Copy link
Member

Choose a reason for hiding this comment

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

뭐하는 파일이에요?



public BigDecimal add(BigDecimal first, String second) {

Copy link
Member

Choose a reason for hiding this comment

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

공백제거

import java.math.BigDecimal;
import java.util.ArrayList;

class Cal {
Copy link
Member

Choose a reason for hiding this comment

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

public? private? default?

class Cal {


public BigDecimal add(BigDecimal first, String second) {
Copy link
Member

Choose a reason for hiding this comment

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

float, long, double은 지원하지 않나요?

class Cal {


public BigDecimal add(BigDecimal first, String second) {
Copy link
Member

Choose a reason for hiding this comment

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

세개 넣으면 돌아가나요?

BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String str = bf.readLine();
return split(str);
} catch (Exception e) {
Copy link
Member

Choose a reason for hiding this comment

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

어떤 exception인가요?
예를 들어 InvalidArgumentException?, MathaticalException? 등 명시적으로 예측 가능한 Exception을 남겨주세요

try {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String str = bf.readLine();
return split(str);
Copy link
Member

Choose a reason for hiding this comment

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

이해가 쉽게 안가는거 같은데 설명 부탁드려요

}
public void calculateStart(String[] str) {
try {
BigDecimal result = new BigDecimal(str[0]);
Copy link
Member

Choose a reason for hiding this comment

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

0번 인덱스 데이터가 의미하는게 뭐에요?

public void calculateStart(String[] str) {
try {
BigDecimal result = new BigDecimal(str[0]);
if (str.length % 2 == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

왜 잘못된거에요?

if (str.length % 2 == 0) {
throw new IllegalArgumentException("잘못된 입력 입니다.");
}
for (int i = 0; i < str.length - 2; i += 2) {
Copy link
Member

Choose a reason for hiding this comment

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

숫자가 네자리라면 동작이 들어갈까요?

@Livenow14 Livenow14 closed this Feb 21, 2021
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.

3 participants