Memoization is a simple optimisation technique to understand and in most cases implement.
The base idea is to speed up function calls by avoiding the re-calculation of previously processed input results (very cache-like).
Storing these results in a key-value lookup store can result in major speed increases when repetitive function calls occur.
When you first take a look at Laravel you may ask yourself, what is with all the static?
It is a valid question, as on the surface it can seem like the framework is heavily static method based.
However, this could be no further from the truth, a deeper exploration reveals that the static calls we make really mask a great amount of instance objects.
In this post I hope to provide a simple explanation as to what is really going on, and along the way build a basic implementation to practice these new found findings.
Having a website that is heavily software-development based, one important aspect that can not be overlooked is well presented code examples.
Speaking on the importance of editor syntax highlighting in the previous episode of our podcast, this attribute transcends over to aid in the readability of code online.
Fortunately, there are many options to choose from, whether it is storing the code snippets in an embedded Gists or using the front-end based highlight.js or Google Code Prettify.
One benefit that greatly simpled the publishing process when using a front-end based solution was that you could simply parse the Markdown file (maybe with a class language type-hint), and leave all the hard work for the client’s browser.
As we all know, we have very little control over the viewing experience per user, and as I have started to post more frequently, cracks began to appear in the syntax highlighters I had been using.
However, when looking for a solution, one had been staring me straight in the face all this time, that being Pygments.
Heapsort is a sorting algorithm which can be split into two distinct stages.
The first stage is to build a tree-based heap data structure from the supplied input.
Conforming to the heap property either requires the structure follow that all parent nodes are greater than or equal to their children (with the highest at the root), or the inverse.
After experimenting with the XOR swap method in Java I had hoped to follow it up with exploration of the XOR double linked-list.
Java objects however, are not directly accessible through pointer reference.
This is by no means a limitation, allowing the Garbage collector to efficiently and safely handle memory allocation.
Sometimes it is desired to have such access however, and you can take advantage of JNI to call assembly, or C/C++ code from within Java.
Another option is to use the sun.misc.Unsafe class, providing many ‘unsafe’ operations, one of which is to retrieve object memory address locations.