標籤彙整: java 教學 書

Java Tip 135: Layer and compare property files

Property files offer an elegant solution for storing program settings loaded at runtime. The elegance comes from the hierarchical naming scheme, the ability to override settings on the command line, and the idea of default properties. Earlier generations of settings files like .rc (read command) or .ini (initialize) files lack these features. Default properties are underutilized, however, probably because good examples are rare and no tools support comparing and manipulation.

The problem with one big property file is that developers inevitably need conflicting settings, and the settings might significantly differ for coding, testing, and deployment. The most common way to express these conflicts, or shall I say, alternatives, is by including commented-out settings. But this strategy does not work well for automated builds, and writing comments about what part should be uncommented and why requires effort. Some try to solve this problem by creating many property files that have overlapping definitions, but this leads to the developer either editing many files to keep them consistent or enduring the inconsistencies as they crop up—both of which waste time. Another common way to accommodate differing properties is to set them on the command line, but this quickly grows messy, and who wants to commit messy start-up scripts to source code control to share usage examples?

To read this article in full, please click here

閱讀全文

分類: IT 資訊科技(信息技术), java 1 對 1 私人補習, 熱門新聞 | 標籤: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | 在〈Java Tip 135: Layer and compare property files〉中留言功能已關閉

Java Tip 134: When catching exceptions, don’t cast your net too wide

Java’s compile-time checking does a pretty good job of keeping exceptions safely caged—you can’t call a method that throws a checked exception without catching the exception or declaring that your own method throws that exception. (For a great discussion on checked and unchecked exceptions and when to use each, see “Designing with Exceptions” (JavaWorld, 1998).) The compiler will also sometimes stop you from catching an exception that isn’t thrown in the try block, but not always, and not when you need it most. This Java Tip discusses this second compile-time check.

To read this article in full, please click here

閱讀全文

分類: IT 資訊科技(信息技术), java 1 對 1 私人補習, 熱門新聞 | 標籤: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | 在〈Java Tip 134: When catching exceptions, don’t cast your net too wide〉中留言功能已關閉

Java Tip 134: When catching exceptions, don’t cast your net too wide

Java’s compile-time checking does a pretty good job of keeping exceptions safely caged—you can’t call a method that throws a checked exception without catching the exception or declaring that your own method throws that exception. (For a great discussion on checked and unchecked exceptions and when to use each, see “Designing with Exceptions” (JavaWorld, 1998).) The compiler will also sometimes stop you from catching an exception that isn’t thrown in the try block, but not always, and not when you need it most. This Java Tip discusses this second compile-time check.

To read this article in full, please click here

閱讀全文

分類: IT 資訊科技(信息技术), java教學網站, 熱門新聞, 科技趣聞 | 標籤: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | 在〈Java Tip 134: When catching exceptions, don’t cast your net too wide〉中留言功能已關閉

Java Tip 133: More on typesafe enums

Many Java developers, including myself, like using the typesafe constant idiom because it provides cleaner code by removing the need to validate whether a constant value is valid or in range. I don’t detail too much here, as the idiom is well documente… 閱讀全文

分類: IT 資訊科技(信息技术), java 1 對 1 私人補習, 熱門新聞 | 標籤: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | 在〈Java Tip 133: More on typesafe enums〉中留言功能已關閉

Java Tip 133: More on typesafe enums

Many Java developers, including myself, like using the typesafe constant idiom because it provides cleaner code by removing the need to validate whether a constant value is valid or in range. I don’t detail too much here, as the idiom is well documente… 閱讀全文

分類: IT 資訊科技(信息技术), java教學網站, 熱門新聞, 科技趣聞 | 標籤: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | 在〈Java Tip 133: More on typesafe enums〉中留言功能已關閉

Java Tip 132: The taming of the thread

Threads can be nasty beasts. This is partly attributed to their delicate nature. Threads can die. If the causes of thread death are not in your code, then MutableThread may keep your code running. This article explores a solution using an object-orient… 閱讀全文

分類: IT 資訊科技(信息技术), java 1 對 1 私人補習, 熱門新聞 | 標籤: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | 在〈Java Tip 132: The taming of the thread〉中留言功能已關閉

Java Tip 132: The taming of the thread

Threads can be nasty beasts. This is partly attributed to their delicate nature. Threads can die. If the causes of thread death are not in your code, then MutableThread may keep your code running. This article explores a solution using an object-orient… 閱讀全文

分類: IT 資訊科技(信息技术), java教學網站, 熱門新聞, 科技趣聞 | 標籤: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | 在〈Java Tip 132: The taming of the thread〉中留言功能已關閉

Java Tip 131: Make a statement with javac!

Often you may want to test a single piece of code. For example, say you forget how the % operator works with negative numbers, or you must determine how a certain API call operates. Writing, compiling, and running a small program repeatedly just to tes… 閱讀全文

分類: IT 資訊科技(信息技术), java 1 對 1 私人補習, 熱門新聞 | 標籤: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | 在〈Java Tip 131: Make a statement with javac!〉中留言功能已關閉

Java Tip 131: Make a statement with javac!

Often you may want to test a single piece of code. For example, say you forget how the % operator works with negative numbers, or you must determine how a certain API call operates. Writing, compiling, and running a small program repeatedly just to tes… 閱讀全文

分類: IT 資訊科技(信息技术), java教學網站, 熱門新聞, 科技趣聞 | 標籤: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | 在〈Java Tip 131: Make a statement with javac!〉中留言功能已關閉

Java Tip 130: Do you know your data size?

Recently, I helped design a Java server application that resembled an in-memory database. That is, we biased the design toward caching tons of data in memory to provide super-fast query performance.Once we got the prototype running, we naturally decide… 閱讀全文

分類: IT 資訊科技(信息技术), java教學網站, 熱門新聞, 科技趣聞 | 標籤: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | 在〈Java Tip 130: Do you know your data size?〉中留言功能已關閉