Java Practices->Home

Web Name: Java Practices->Home






Java Practices offers concise presentations of Java practices, tasks, and designs, illustrated with syntax-highlighted code examples. Some general-purpose references are provided, along with some source code. See below for user comments on the site.

Simplicity does not precede complexity, but follows it. - Alan Perlis, Epigrams In Programming

Generalities Coding conventions Minimize ripple effects Avoid basic style errors Wisdom, not rules Modularity and deletion Copy paste is dangerous Know the common sources of complexity Constructors Constructors in general Construct Object using class name Copy constructors Initializing fields to 0 false null is redundant Beware of mistaken field redeclares Constructors shouldn't call overridables Don't pass 'this' out of a constructor Constructors shouldn't start threads Avoid JavaBeans style of construction Overriding Object Methods Implementing compareTo Implementing equals Never rely on finalize Implementing hashCode Implementing toString Avoid clone Inheritance Designing for subclassing Consider composition instead of subclassing Overridable methods need special care Remember styles of inheritance Collections Ways of iterating Encapsulate collections Use for each liberally Use interface references to Collections Remove from a collection Prefer Collections over older classes Choosing the right Collection Iterate without an index Use standard Collections Exceptions Exception translation Checked versus unchecked exceptions Pass all pertinent data to exceptions Avoid empty catch blocks Avoid @throws in javadoc Exceptions and control flow Use template for repeated try catch Beware of unknown root causes Finally and catch Be specific in throws clause Javadoc all exceptions Stack trace as String Functional Programming Lambdas only for simple cases Understand the functional style Static import of Collectors Annotate functional interfaces Prefer standard functional interfaces Beware forEach terminals Files Buffering usually appropriate Reading and writing binary files Copy a file Open file in native directory Delete a directory tree Copy a directory tree Reading and writing text files Reading and writing Serializable objects Recursive file listing Console input Always close streams Threads Data integrity first Read write locks Perform N tasks in parallel Prefer modern libraries for concurrency Query host for the number of processors Always shut down an ExecutorService Handle InterruptedException Use finally to unlock Dump thread information Remember the types of intrinsic lock Stop threads through cooperation Document thread safety Synchronize access to mutable fields Launch thread is just another user thread Objects communicating across threads Avoid ThreadGroup Thread priorities are not portable Schedule periodic tasks Synchronized is implementation detail Common Design Patterns Type Safe Enumerations Abstract Factory Command objects Template method Model Objects Factory methods Plugin Factory Wrapper (Decorator) Immutable objects Private constructor Singleton Practices Compile regular expressions once Multiple return statements Overloading can be tricky Don't declare local variables before use Consider code generators Avoid null if possible Separate public and private members Defensive copying Test using main method Use enums to restrict arguments Design by Contract Use static imports rarely Use boxing with care Class for constants Extra space in argument list Quote dynamic text when logging Package by feature, not layer Try alternatives to ResourceBundle Validation belongs in a Model Object Beware of DecimalFormat Beware of floating point numbers Include 'from', exclude 'to' Passwords never in clear text Fields should usually be private Use @Override liberally Avoid raw types Use final liberally Use a fake system clock Tag or marker interfaces Don't use tab characters Structs are occasionally useful Beware of Byte Order Marks Nest classes with care Prefer modern date classes Short public methods Return Optional not null Varargs for 1 to N Don't let var hide essential info Uncommon classes need explicit imports Beware of instanceof operator Interface for constants Use a testing framework (JUnit) Lazy initialization Output parameters Do not break portability String concatenation does not scale Know the core libraries Validate method arguments Generating unique IDs Naming conventions Prefer empty items to null ones Validate state with class invariants Use javadoc liberally Conventional name for return value Conditional compile Construct classes from the outside in Consider immutable forms for dates Use System.exit with care Clarifying method Self encapsulate fields Tasks Pattern match lines of a file Representing money Arrays as String Logging messages Send an email Examine bytecode Fetch text from the web Determine if Strings are equal Compare and sort Strings Modernize old code Read jar version information Implement code tables Command line operations Run in debug mode Memory stats Define app name once Copy an array Measure application performance Recovering resources Generate random numbers Internationalization Replace a substring Clipboard copy and paste Get size of object in memory Time execution speed Parse text Servlets and JSPs Refactor large Controllers Use Model View Controller framework Always maintain HttpSessions Session scope objects often Serializable Do not synchronize doGet, doPost JSPs should contain only presentation logic Beware of custom cookies Repel invalid requests Parse parameters into domain objects Thread safety in web apps Loss of data during restart Prefer JSTL tags Use templates to standardize layout Pre populate forms Prevent self linking Send trouble ticket emails Validate email addresses Forward versus redirect A Web App Framework WEB4J Manage sessions closely Struts seems mediocre Choose form validation style carefully Beware of doubly escaped ampersands Use Cascading Style Sheets Beware multilingual submit buttons Prefer UTF 8 in all layers Beware of common hacks Understand details of FORM tags Consider Controllers for redirects Reuse login page for errors Wrap file upload requests Use extensions for fine grained security Beware of URL rewriting Serve binary content Version links to CSS and JS Hide .html and .jsp Sessions shared across tabs Apply correct redirect code Minimize site response time Web usability guidelines Emit flexible URLs Escape special characters Validate generated HTML Measure web app performance Serialization Some classes need readResolve Implementing Serializable Serialization and subclassing Assertions Assert is for private arguments only Assertions in general Assert use cases Force enabling of assertions Databases Keep SQL out of code Don't perform basic SQL tasks in code Consider data layer tools Get database connection Consider using standard SQL Encapsulate connections Simplify database operations Use template for transactions Business identifiers as String Consider wrapper classes for optional data Try pseudo persistence for mock ups Data is king Prefer PreparedStatement Remember the basics of database design Data access objects Connection pools Reduce database code duplication Data exception wrapping Swing Look and Feel guidelines Splash screen Standardized dialogs Verify input with regular expressions Swing utility tasks Swing threads Preferences dialogs Using preferences Observers and listeners Using JavaHelp Change theme Actions Timers Sort table rows Filter table rows Swing in general Layout Managers Input dialogs Render table cells Align menu items A Swing App StocksMonitor Don't subclass JDialog or JFrame Provide an uncaught exception handler Don't bury dialogs Minimal Swing application Verify input with Model Objects Consider JGoodies Forms for layouts Launch other applications Tools Using Ant for build scripts Use Version Control tools Using Tomcat for servlets Using Maven for builds 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!"
Java Practices 3.011
© 2018 Hirondelle Systems
Source Code |Contact |License |RSS
Individual code snippets have a BSD license
Over 1,000,000 unique IPs last year
Last updated
- In Memoriam : Bill Dirani -

TAGS:Practices Java Home gt

<<< Thank you for your visit >>>

Websites to related :
OJO Home - Homes for Sale, MLS L

  .spinnerholder{position: fixed; background-color: white; top:0;left: 0;bottom: 0;right: 0;z-index: 99999;}.spinner {position: fixed;border: 4px solid

Home - Center for Medical Econom

   HomeAboutScholarsIssuesPrice &#038; CostsValueInnovationPolicy ProposalsCoronavirusResourcesStudiesBriefsCoverage Denied –

PayLive - Home

Payment SystemToggle navigation Home Overview Abo

Bike Perfect | The Home of Bike

  Skip to main contentBike Perfect Bike Perfect Search RSS (opens in new tab) (opens in new tab) (opens in new tab) (opens in new tab)NewsReviewsBuy

Home | Ryo Okumoto

  Ryo Okumoto Official WebsiteMenu Home

Home | Act Now!

  Skip to main content

Cosma's Home Page


Puget Sound Bonsai Association,

  Puget Sound Bonsai Association

HOME - Geopolitical Economy Rese


Home | Guernsey Finance

   耿西金融局 商业目录 联系我们


Hot Websites