Java

[Effective Java] ์•„์ดํ…œ 22. ์ธํ„ฐํŽ˜์ด์Šค๋Š” ํƒ€์ž…์„ ์ •์˜ํ•˜๋Š” ์šฉ๋„๋กœ๋งŒ ์‚ฌ์šฉํ•˜๋ผ.

quedevel 2023. 3. 20. 10:07
728x90
๋ฐ˜์‘ํ˜•

๐ŸŽฏ ์•„์ดํ…œ 22. ์ธํ„ฐํŽ˜์ด์Šค๋Š” ํƒ€์ž…์„ ์ •์˜ํ•˜๋Š” ์šฉ๋„๋กœ๋งŒ ์‚ฌ์šฉํ•˜๋ผ.

โญ ์ธํ„ฐํŽ˜์ด์Šค๋Š” ์ž์‹ ์„ ๊ตฌํ˜„ํ•œ ํด๋ž˜์Šค์˜ ์ธ์Šคํ„ด์Šค๋ฅผ ์ฐธ์กฐํ•  ์ˆ˜ ์ž‡๋Š” ํƒ€์ž… ์—ญํ• ์„ ํ•œ๋‹ค.

๋‹ฌ๋ฆฌ ๋งํ•ด, ํด๋ž˜์Šค๊ฐ€ ์–ด๋–ค ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๊ตฌํ˜„ํ•œ๋‹ค๋Š” ๊ฒƒ์€ ์ž์‹ ์˜ ์ธ์Šคํ„ด์Šค๋กœ ๋ฌด์—‡์„ ํ•  ์ˆ˜ ์žˆ๋Š”์ง€๋ฅผ ํด๋ผ์ด์–ธํŠธ์— ์• ๊ธฐํ•ด์ฃผ๋Š” ๊ฒƒ์ด๋‹ค.

์ธํ„ฐํŽ˜์ด์Šค๋Š” ์˜ค์ง ์ด ์šฉ๋„๋กœ๋งŒ ์‚ฌ์šฉํ•ด์•ผํ•œ๋‹ค.

  • ์ƒ์ˆ˜ ์ธํ„ฐํŽ˜์ด์Šค ์•ˆํ‹ฐํŒจํ„ด - ์‚ฌ์šฉ ๊ธˆ์ง€!
public interface PhysicalConstants {
    // ์•„๋ณด๊ฐ€๋“œ๋กœ ์ˆ˜ (1/๋ชฐ)
    static final double AVOGADROS_NUMBER = 6.022_140_857e23;
    // ๋ณผ์ธ ๋งŒ ์ƒ์ˆ˜ (J/K)
    static final double BOLTZMANN_CONSTANT = 1.380_648_52e-23;
    // ์ „์ž ์งˆ๋Ÿ‰ (kg)
    static final double ELECTRON_MASS = 9.109_383_56e-31;
}

1๏ธโƒฃ ํด๋ž˜์Šค ๋‚ด๋ถ€์—์„œ ์‚ฌ์šฉํ•˜๋Š” ์ƒ์ˆ˜๋Š” ์™ธ๋ถ€ ์ธํ„ฐํŽ˜์ด์Šค๊ฐ€ ์•„๋‹ˆ๋ผ ๋‚ด๋ถ€ ๊ตฌํ˜„์— ํ•ด๋‹นํ•œ๋‹ค.

2๏ธโƒฃ ์ƒ์ˆ˜ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒƒ์€ ์ด ๋‚ด๋ถ€ ๊ตฌํ˜„์„ ํด๋ž˜์Šค์˜ API๋กœ ๋…ธ์ถœํ•˜๋Š” ํ–‰์œ„์ด๋‹ค.

3๏ธโƒฃ ํด๋ž˜์Šค๊ฐ€ ์–ด๋–ค ์ƒ์ˆ˜ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์‚ฌ์šฉํ•˜๋“  ์‚ฌ์šฉ์ž์—๊ฒŒ๋Š” ์•„๋ฌด๋Ÿฐ ์˜๋ฏธ๊ฐ€ ์—†๋‹ค.

4๏ธโƒฃ ๋‹ค์Œ ๋ฆด๋ฆฌ์Šค์—์„œ ์ด ์ƒ์ˆ˜๋“ค์„ ๋”๋Š” ์“ฐ์ง€ ์•Š๊ฒŒ ๋˜๋”๋ผ๋„ ๋ฐ”์ด๋„ˆ๋ฆฌ ํ˜ธํ™˜์„ฑ์„ ์œ„ํ•ด ์—ฌ์ „ํžˆ ์ƒ์ˆ˜ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๊ตฌํ˜„ํ•˜๊ณ  ์žˆ์–ด์•ผ ํ•œ๋‹ค.

์ฐธ๊ณ  ์ž๋ฃŒ

Joshua Bloch, ใ€ŽEffective Java 3/Eใ€, ๊ฐœ์•ž๋งต์‹œ ์˜ฎ๊น€, ํ”„๋กœ๊ทธ๋ž˜๋ฐ์ธ์‚ฌ์ดํŠธ(2018)
http://www.kyobobook.co.kr/product/detailViewKor.laf?ejkGb=KOR&mallGb=KOR&barcode=9788966262281&orderClick=LEa&Kc=

728x90
๋ฐ˜์‘ํ˜•