Product Description
-
Popularity
Target students are anyone who likes coding, especially Java programmers and developers who look for quality, productivity and success in his/her software career.
-
Practicality
Through practice in the class and at home, you will grasp good coding habit and discipline, one at a time, to be experienced software professional, art of writing agile and highly maintainable software.
-
Workability
New features of Java 6 through 9 are also covered.
The course is mainly based on 3 books: Effective Java, Clean Code, and Design patterns (GOF book).
Course Description
This course talks about customary and effective use of Java. We systematically present advice on how to write clean and reusable code, with solid object-oriented structure, following proved design patterns. We will talk what works, what doesn’t, how to use Java and its libraries to best effect. Real code and API examples are run and examined.
1. Creating and Destroying Objects
- Consider static factory methods instead of constructors
- Consider a builder when faced with many constructor parameters
- Enforce the singleton property with a private constructor or an enum type
- Enforce noninstantiability with a private constructor
- Avoid creating unnecessary objects
- Eliminate obsolete object references
- Avoid finalizers
2. Methods Common to All Objects
- Obey the general contract when overriding equals
- Always override hashCode when you override equals
- Always override toString
- Override clone judiciously
- Consider implementing Comparable
3. Classes and Interfaces
- Minimize the accessibility of classes and members
- In public classes, use accessor methods, not public fields
- Minimize mutability
- Favor composition over inheritance
- Design and document for inheritance or else prohibit it
- Prefer interfaces to abstract classes
- Use interfaces only to define types
- Prefer class hierarchies to tagged classes
- Use function objects to represent strategies
- dFavor static member classes over nonstatic 1
4. Generics
- Don’t use raw types in new code
- Eliminate unchecked warnings
- Prefer lists to arrays
- Favor generic types
- Favor generic methods
- Use bounded wildcards to increase API flexibility
- Consider typesafe heterogeneous containers
5. Enums and Annotations
- Use enums instead of int constants
- Use instance fields instead of ordinals
- Use EnumSet instead of bit fields
- Use EnumMap instead of ordinal indexing
- Emulate extensible enums with interfaces
- Prefer annotations to naming patterns
- Consistently use the Override annotation
- Use marker interfaces to define types
6. Methods
- Check parameters for validity
- Make defensive copies when needed
- Design method signatures carefully
- Use overloading judiciously
- Use varargs judiciously
- Return empty arrays or collections, not nulls
- Write doc comments for all exposed API elements
7. General Programming
- Minimize the scope of local variables
- Prefer for-each loops to traditional for loops
- Know and use the libraries
- Avoid float and double if exact answers are required
- Prefer primitive types to boxed primitives
- Avoid strings where other types are more appropriate
- Beware the performance of string concatenation
- Refer to objects by their interfaces
- Prefer interfaces to reflection
- Use native methods judiciously
- Optimize judiciously
- Adhere to generally accepted naming conventions
8. Exceptions
- Use exceptions only for exceptional conditions
- Use checked exceptions for recoverable conditions and runtime exceptions for programming errors
- Avoid unnecessary use of checked exceptions
- Favor the use of standard exceptions
- Throw exceptions appropriate to the abstraction
- Document all exceptions thrown by each method
- Include failure-capture information in detail messages
- Strive for failure atomicity
- Don’t ignore exceptions
9. Concurrency
- Synchronize access to shared mutable data
- Avoid excessive synchronization
- Prefer executors and tasks to threads
- Prefer concurrency utilities to wait and notify
- Document thread safety
- Use lazy initialization judiciously
- Don’t depend on the thread scheduler
- Avoid thread groups
10. Serialization
- Implement Serializable judiciously
- Consider using a custom serialized form
- Write readObject methods defensively
- For instance control, prefer enum types to readResolve
- Consider serialization proxies instead of serialized instances
Jigang Hao
Professor of USJ
Dr. Hao received his PhD of Computer Science at Tsinghua University. He is a senior scientist at Oracle, a big data expert at USJ. He has worked for Peoplesoft, Ebay, Visa, Boeing, Apple etc.
Reviews
There are no reviews yet.