I write mainly about programming (EN/PL) (Java, Python, Go, JavaScript), play with generative art using p5js and I'm an author and illustrator of my children's books.
Task appropriate for the job high parallelization : use fork-join pool and and parallel streams for highly CPU-bound calculations high interactivity: high concurrency and a need to keep a lot of IO-bound tasks on single CPU: use Future (Completable Future) or Flow API Problems and solutions Threads problems map 1:1 to OS threads (expensive to create and of limited number) much higher number than hardware threads (cores? well, it seems a core is more complex) CPUs like the Intel i7-6900K have multiple hardware threads per core, so the CPU can execute useful instructions even for short delays such as a cache miss.
Reasons to abandon old API java.util.Date mutable unintuitive constructor (days, months, minutes and seconds are 0-based, year represented as delta from 1900), values wrap-around cannot be internationalized java.util.Calendar not thread safe mutable (no clear semantics date change) when to use which? java.util.DateFormat not thead-safe can only parse Date, not Calendar New API java.time package Classes and interfaces in a new package java.time (modelled after Joda Time classes) provide better way of thinking about and working with time concepts.
Null problem Reasons why null is problematic:
source of coding errors (missing checks) does not correctly model absence of value (null has no meaning) breaks Java philosophy of hiding pointers (null is a pointer which is NOT hidden) Handling in other languages Groovy has safe navigation operator Kotlin is known for its null-safety Haskell has Maybe typeclass Scala also has an Option class Optional Creating Three static methods may create instances of Optional:
Refatoring Here are three simple refactorings that can be used if you want to migrate your codebase to Java 8 (or higher). You may want to do so for many different reasons (readability, conciseness, code reuse, security).
Refactoring anonymous classes to lambda expressions Refactoring lambda expressions to method references Refactoring imperative-style data processing to streams Recommended paper about automatic refactoing of pre-Java 8 codebases into Java8: Lambda Refactoring
Gotchas different meaning of this and super (in lambda this refers to enclosing class, in inner class - to itself) lambdas cannot (and anonymous inner classes can) shadow enclosing class variables Code flexibility Question: when to introduce functional interfaces?