Baeldung newsletter, Check Out the Guava Cache

Guava is definitely a very cool library. It ticks all the right boxes – it’s actively developed, intelligently designed and helps with just about everything.
Let’s start with their Caching implementation; if you’ve been using a HashMap to cache anything, please follow these steps:

  1. apply a sharp slap to your own wrist
  2. read this article
  3. use the Guava Cache

>> THE GUAVA CACHE (DON’T USE A HASHMAP)

My Pluralsight recommended courses

In the last couple of months I have been doing quite a lot of Pluralsight Courses, and I thought I could compile a list with the highly recommended
(my profile on pluralsight)

1. Java Performance Tuning – mind blowing I have learned so much. Trust me and check out this course.

2. If you are new to docker (like I was) and want to learn it, I recommend
Docker and Kubernetes: The Big Picture – Really Enjoyed this one!
Docker Deep Dive

3. I really learned a lot about linux from:
Getting Started with Linux

JVM Internals

Found this amazing post about JVM Internals – JVM Internals

Some excerpts:

In the Hotspot JVM there is a direct mapping between a Java Thread and a native operating system Thread.

__
Another great source
https://www.artima.com/insidejvm/ed2/jvm6.html

The Java virtual machine specification is silent on how objects should be represented on the heap. Object representation–an integral aspect of the overall design of the heap and garbage collector–is a decision of implementation designers

We don’t rise to expectations, we fall to our level of training.

RiseToExpectation-Fall2Training

When the rubber hits the road, and you’re in the middle of intense work on your project, the code you produce is the result of your regular/habitual way of coding.
In those moments you don’t have the time, the dispositon(mindset) to produce a higher code quality. You just want(have) to get the task done, because there’s a lot more tasks on your plate, and you need to get this project done already.

In those moments you will always fall to your average(default/worst) way of coding.
Do you stick to Single responsibility principle ?
Do you stick to DRY?
Do you stick to short/simple methods?
Do you stick to writing testable code?
Do you stick to covering your code with test?
Do you really know your API/Library/Framework, and do you use it in most effective way?

If these are not in your default way of writing code, then just aspiring to doing all these in your next new project, is just naive wishful thinking.

You have to integrate these in the way you code thru training and exercise, or else you’ll just produce the same old code.

How to iterate a matrix. Matrix mental model.

row_column_indexes18831

Whenever I had to deal with matrices(bi-dimensional array), I had to struggle a bit how to iterate them.. you know the classic imbricated for loop from school …


for(int i=0; i<matrix.len; i++)
for(int j=0;... j++)

But here is my mental model which helps me better understand matrix iteration.

I think about a matrix is just like a ‘normal'(one-dimensional) array, whose elements are arrays themselves.
so in String[][] myMatrix the first part – String[] is the main array, and the second part [] refers to the array within(of) the main array

So, matrix[2][0] means – I want to access in the matrix the element at index 2(circled in red) – which gives me an array of String: String[3] subArray and from that row/subArray we get the element at index 0

Screenshot 2020-06-06 at 11.59.57

 How to iterate?

I) From Up to Down -> go to the i row
a[i] returns us the row(subArray) at index i

II) From Left to Right, -> in that row, go to the j element
a[][j] once we’re on the desired row, to j iterator returns us the desire element from the given row

How_to_Iterate_Matrix_20200606_102457__01__01

  for (int rowIdx = 0; rowIdx < matrix.length; rowIdx++) {
            T[] oneLine = matrix[rowIdx];
            for (int colIdx = 0; colIdx < oneLine.length; colIdx++) {
                oneLine[colIdx] = valProducer.apply(new RowColPair(rowIdx, colIdx));
            }
        }