일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- CPU
- Code complete
- network
- 명령어
- 가독성
- Sector
- private ip
- TCP
- register
- float
- L2 switch
- 코드 컴플릿
- MMU
- interrupt
- ALU
- Clean code
- 클린 코드
- 리펙토링
- page
- ack
- cache
- addressing mode
- 공인 IP
- Public IP
- floating point
- osi 7
- refactoring
- L3 Router
- physical address
- 사설 IP
- Today
- Total
목록refactoring (21)
Software Lab

i=i+1 //산술 연산자 i+=1 //산술 연산자 i++ //증감 연산자, 후위 연산 ++i //증감 연산자, 전위 연산 i=i-1 //산술 연산자 i-=1 //산술 연산자 i-- //증감 연산자, 후위 연산 --i //증감 연산자, 전위 연산 정수형 변수에 1을 더하거나 빼려면 산술 연산자나 증감 연산자를 사용하는 방법이 있다. CPU에서 증감 연산자가 산술 연산자보다 더 적은 클록을 사용한다. 때문에 증감 연산자 처리 속다가 더 빠르다. 증감 연산자에서도 후위 연산과 전위 연산 두 가지로 나뉘는데, 전위 연산의 속도가 더 빠르다. http://wiki.hash.kr/index.php/%EC%A6%9D%EA%B0%90%EC%97%B0%EC%82%B0%EC%9E%90 현대의 컴파일러는 최적화를 잘한다...

let value = false function toggle(){ if(value == false) value = true else value = false } let value = false function toggle(){ value = !value } 변수를 true와 false로 토글 하고 싶은 경우, not 연산자 (!) 사용하면 된다.

function isAdult(age){ if(age >= 18) return true else return false } function isAdult(age){ return (age >= 18) ? true : false } function isAdult(age){ return (age >= 18) } 간단한 비교 연산의 경우, 삼항 연산자를 사용할 수 있다. 비교 연산 후 결과가 간단하게 true, false라면 더 축약하여 사용할 수 도 있다.

const array = [1, 2, 3, 4] 이터레이터는 여러가지 종류가 있다. 모두 기능이 비슷해 보이지만, 분명한 차이가 있다. 그것들을 이해하고 목적에 맡게 사용해야 한다. 위의 array에 대해 각각의 이터레이터를 사용해 보자. for(let i = 0; i { console.log(v) return (v == 3)..

class Line{ Point start; Point end; public void setStart(Point point){ this.start = start; } public void setEnd(Point point){ this.end = end; } public void draw(){ if(self.start == null) return; if(self.end == null) return; .... .... } } void main(){ Line line = new Line(); line.setStart(new Point(10, 10)); line.setEnd(new Point(20, 30)); line.draw(); } class Line{ Point start; Point end; privat..

public void writeLog(int actor, String log){ try{ String actorString = actorToString(actor); String timeStamp = new SimpleDateFormat("MM.dd.HH.mm.ss").format(new Date()); FileWriter writer = new FileWriter("system.log"); writer.write("[" + timeStamp + "]" + "" + log); writer.close(); } catch(Exception e){ println(e.ToString()); } } public void writeLog(int actor, String log){ String actorString ..

drawLine(Point start, Point end){ // define func if(start == null || end == null) return; .... .... } drawLine(start, end) // call func drawLine(Point start, Point end){ // define func .... .... } if(start != null && end != null) drawLine(start, end) // call func 는 오동작이 발생할 수 있다. 는 함수 외부에서 매번 null 처리 코드를 작성할 필요가 없다. 그리고 만약 인자가 null인 경우 죽지 않으므로 안전하게 동작한다고 착각할 수 있다. 그런데 죽지 않는다고 문제가 없는 것인가? null 인자..

if(this.user == ''){ alert('require login') return } else if(this.title == ''){ alert('no title') return } else if(this.content == ''){ alert('no content') return } else if(this.image == ''){ alert('no image') return } await postContent(this.title, this.content, this.image) const checkList = [ [this.user, 'require login'], [this.title, 'no title'], [this.content, 'no contents'], [this.image, 'no..