Java/BestPractices
From charlesreid1
Java best practices:
- When to use what type of container - trees are O(log N), sorted. hashes are O(1), not sorted.
- Comparators vs comparable - how to maximize utility of comparators (e.g., PriorityQueue)
- Iterator vs iterable - how and when to roll your own, how and when to be lazy.
- Class import statements:
- Rigorously, we do "import java.util.LinkedList;" BUT
- Informally we do "import java.util.*; import java.io.*"
- Why/when/how is this dangerous in Java.
- Organization of classes:
- Start with main method
- Move on to utility/protected/private classes, iterators/iterables, items, etc.
- Finally, include class content at bottom (it is at end, because that's the "least surprising" part of the code.)
Computer Science notes on computer science topics on the wiki, for educational and learning purposes
Part of the 2017 CS Study Plan.
Python/Exceptions · Python/Assertions · Python/Decorators Python/Os (os module) · Python/Strings Python/Splat · Python/Iterators · Python/Generators Python/Comparators · Python/Lambdas
Builtin features of Java: Java/Exceptions · Java/Assertions · Java/Memory · Java/Interfaces Java/Generics · Java/Decorators · Java/Diamond Notation Java/Iterators · Java/Iterable · Iterators vs Iterable Java/Comparators · Java/Comparable · Comparators vs Comparable Java/Numeric · Java/TypeChecking · Java/Testing · Java/Timing · Java/Profiling Documentation: Javadocs · Java/Documentation Tools and functionality: Java/URLs · Java/CSV External libraries: Guava · Fastutil · Eclipse Collections OOP: OOP Checklist · Java/Abstract Class · Java/Encapsulation · Java/Generics
|
See also: