Day 7

πŸ”– 였늘 읽은 λ²”μœ„: 3μž₯ 의미 μžˆλŠ” 이름 pt.2

πŸ˜ƒ μ±…μ—μ„œ κΈ°μ–΅ν•˜κ³  싢은 λ‚΄μš©μ„ μ¨λ³΄μ„Έμš”.

  • λΆ€μˆ˜ 효과λ₯Ό μΌμœΌν‚€μ§€ 마라.

  • "좜λ ₯" μΈμˆ˜λŠ” κ°€λŠ₯ν•œ ν”Όν•œλ‹€: 일반적으둜 μš°λ¦¬λŠ” 인수λ₯Ό ν•¨μˆ˜ "μž…λ ₯"으둜 μƒκ°ν•œλ‹€.

  • ν•¨μˆ˜ μ„ μ–ΈλΆ€λ₯Ό μ°Ύμ•„λ³΄λŠ” ν–‰μœ„λŠ” μ½”λ“œλ₯Ό 보닀가 μ£ΌμΆ€ν•˜λŠ” ν–‰μœ„μ™€ 동급이닀. μΈμ§€μ €μœΌλ‘œ κ±°μŠ¬λ¦°λ‹€λŠ” λœ»μ΄λ―€λ‘œ ν”Όν•΄μ•Ό ν•œλ‹€.

  • 였λ₯˜ μ½”λ“œ λŒ€μ‹  μ˜ˆμ™Έλ₯Ό μ‚¬μš©ν•˜λ©΄ 였λ₯˜ 처리 μ½”λ“œκ°€ μ›λž˜ μ½”λ“œμ„Έμ–΄ λΆ„λ¦¬λ˜λ―€λ‘œ μ½”λ“œκ°€ 깔끔해진닀.

  • 정상 λ™μž‘κ³Ό 였λ₯˜ 처리 λ™μž‘(try/catch)을 λΆ„λ¦¬ν•˜κ³  λ³„λ„μ˜ ν•¨μˆ˜λ‘œ 뽑아내라.

  • κ·Έλž˜λ„ 쀑볡은 λ¬Έμ œλ‹€. μ½”λ“œ 길이가 λŠ˜μ–΄λ‚  뿐 μ•„λ‹ˆλΌ μ•Œκ³ λ¦¬μ¦˜μ΄ λ³€ν•˜λ©΄ λ„€ κ³³μ΄λ‚˜ 손봐야 ν•˜λ‹ˆκΉŒ. κ²Œλ‹€κ°€ μ–΄λŠ ν•œ 곳이라도 λΉ λœ¨λ¦¬λŠ” λ°”λžŒμ— 였λ₯˜κ°€ λ°œμƒν•  ν™•λ₯ λ„ λ„€ λ°°λ‚˜ λ†’λ‹€.

  • ꡬ쑰적 ν”„λ‘œκ·Έλž˜λ° 원칙: λͺ¨λ“  ν•¨μˆ˜μ™€ ν•¨μˆ˜ λ‚΄ λͺ¨λ“  블둝에 μž…κ΅¬μ™€ μΆœκ΅¬κ°€ ν•˜λ‚˜λ§Œ μ‘΄μž¬ν•΄μ•Ό ν•œλ‹€. 즉, ν•¨μˆ˜λŠ” return 문이 ν•˜λ‚˜μ—¬μ•Ό ν•œλ‹€λŠ” 말이닀.

  • goto 문은 큰 ν•¨μˆ˜μ—μ„œλ§Œ μ˜λ―Έκ°€ μžˆμœΌλ―€λ‘œ, μž‘μ€ ν•¨μˆ˜μ—μ„œλŠ” ν”Όν•΄μ•Όλ§Œ ν•œλ‹€.

πŸ€” 였늘 읽은 μ†Œκ°μ€? λ– μ˜€λ₯΄λŠ” 생각을 κ°€λ³κ²Œ μ μ–΄λ³΄μ„Έμš”

ν•¨μˆ˜...λ„ˆλž€ 쑴재 μ–΄λ €μš΄ 쑴재... java μ½”λ“œλ§Œ λ‚˜μ˜€λ©΄ 슬금슬금 ν”Όν•˜κ³  λŒ€λž΅ λ§₯락만 νŒŒμ•…ν•΄μ„œ 읽고 μžˆλŠ”λ° λ‹€λ“€ λ‚˜μ™€ 같은 걸까, λ‚˜λ§Œ 그런 걸까.

πŸ”Ž κΆκΈˆν•œ λ‚΄μš©μ΄ μžˆκ±°λ‚˜, 잘 μ΄ν•΄λ˜μ§€ μ•ŠλŠ” λ‚΄μš©μ΄ μžˆλ‹€λ©΄ μ μ–΄λ³΄μ„Έμš”.

  • void (JavaScript): The void operator evaluates the given expression and then returns undefined. (➑️ Resource )

  • goto (C): The goto statement can be used to alter the flow of control in a program. Although the goto statement can be used to create loops with finite repetition times, use of other loop structures such as for, while, and do while is recommended. ( ➑️ Resource )
    *κ·Έλƒ₯ μ‰½κ²Œ μƒκ°ν•΄μ„œ ν•œ ν•¨μˆ˜ μ•ˆμ—μ„œ λ‹€λ₯Έ λ°˜λ³΅λ¬Έμ„ κ°€μ Έμ˜¬ λ•Œ μ“°μ΄λŠ” λ“―. ν•¨μˆ˜ λ‚˜κ°€λŠ” λ¬Έ(return)이 μ—†κ³ , 문을 μ—΄μ—ˆλ”λ‹ˆ 또 λ‹€λ₯Έ λ°©(반볡문)이 λ‚˜μ˜€λŠ” λŠλ‚Œ...?

μ†Œκ° 3쀄 μš”μ•½

  • λΆ€μˆ˜ 효과λ₯Ό μΌμœΌν‚€μ§€ 마라.
  • 정상 λ™μž‘κ³Ό 였λ₯˜ 처리 λ™μž‘(try/catch)을 λΆ„λ¦¬ν•˜κ³  λ³„λ„μ˜ ν•¨μˆ˜λ‘œ 뽑아내라.
  • 단일 μž…/좜ꡬ κ·œμΉ™ single entry-exit rule: λͺ¨λ“  ν•¨μˆ˜μ™€ ν•¨μˆ˜ λ‚΄ λͺ¨λ“  블둝에 μž…κ΅¬μ™€ μΆœκ΅¬κ°€ ν•˜λ‚˜λ§Œ μ‘΄μž¬ν•΄μ•Ό ν•œλ‹€.

0개의 λŒ“κΈ€