Collected Java Practices
javapractices.com offers concise presentations of Java practices, tasks, and designs,
illustrated with syntax-highlighted code examples. Many code examples are
taken from the WEB4J example application, and
from a Swing application named StocksMonitor.
See below for user comments on the site.
| But I am getting used to the horror of my existence. |
| - The Return Of The Native, Thomas Hardy |
Servlets and JSPs
Swing
Exceptions
Input-Output
| Always close streams | Buffering usually appropriate |
| Console input | Reading and writing Serializable objects |
| Reading and writing text files |
Databases
Collections
Overriding Object Methods
| Avoid clone | Implementing compareTo |
| Implementing equals | Implementing hashCode |
| Implementing toString | Never rely on finalize |
Common Tasks
Common Design Patterns
| Abstract Factory | Command objects |
| Factory methods | Immutable objects |
| Lazy initialization | Model Objects |
| Private constructor | Singleton |
| Template method | Type-Safe Enumerations |
Common Practices
Inheritance
| Consider composition instead of subclassing | Designing for subclassing |
| Overridable methods need special care | Remember styles of inheritance |
More Common Practices
Assertions
| Assert is for private arguments only | Assert use cases |
| Assertions in general | Force enabling of assertions |
Constructors
Serialization
| Implementing Serializable | Serialization and subclassing |
| Some classes need readResolve |
Code Generators
| Code generators in general | Datacentric class generator |
| Type-safe enum generator | Wrapper generator |
Threads
| User Comments | |
| "I just wanted to take a second to say that this site is really useful. It's not all that often that I come across a site that has some good design information without a bunch of boring fluff. It reminds me of reading Effective Java, which I would consider to be one of the best books I've ever picked up." | |
| "I love this site. It's one of the best laid out and most useful sites that I've ever used. Thank you very much." | |
| "First I have to say, what a great site. We were thinking about starting something similar inside the company, but what better news than to hear that someone has done it for us. Keep up the great work." | |
| "I do think this site is excellent. Keep it up." | |
| "Awesome for a beginner like me!" | |
| "A Great Site!!! I refer to it often. I really enjoy your common sense and straight forward, flexible approach to these issues. Thanks!" | |
| "Thanks for a great site, it really stands out from the crowd. Keep up the good work!" |
|