“Chunk” is one of the coolest words in the English language. Chunking is also a very useful algorithm technique where we split arrays into separate parts. Although there are many way to split an array, we are going to use a traditional for loop. Our pseudo code will look something…
Algorithm Patterns 101: Character Mapping
You will often be ask questions in interview settings that involve finding patterns within strings. In order to correctly track and correlate where characters exist, we need to use something called a character map. In this scenario, I am attempting to turn my name “Teddy” into a char map. While…
Algorithm Patterns 101: Sliding Window
The sliding window pattern is used to process sequential data by maintaining a moving subset of elements. When we first start our algorithm journey our first inclination is to use nested loops. Sliding window is aimed at reducing our habit of using nested loops. A “window” is a data structure…
Algorithm Patterns 101: Fast and Slow Pointers
Similar to two pointers, fast and slow pointers use two pointers to traverse data structures. But this comes with one key difference, the pointers iterate at different speeds. The pointers can be used to traverse the array or list in either direct, BUT one must move faster than the other….
Algorithm Patterns 101: Two-Pointer
Two pointers is simply an alogorithm pattern that uses multiple pointers to iterate over a collection. What is a “pointer”? A pointer is just a number that stores where you are at. Almost like a bookmark, it keeps track and indexes the current place you are iterating. Why do we…
Builder Pattern Explained Simply
The Builder pattern is useful for creating complex objects that need step-by-step assembly. Or put more specifically, when a constructor just doesn’t do the trick anymore… Builders are incredibly common and you are already using them. For instance: Builders “chain together” methods and allow you to append method one after…
Iterator Pattern Explained Simply
An iterator is simply an object that is used to traverse a data structure. Unless you are working on an old Java code base, iterator patterns are going to be few and far between. Although rare, many of the features we take for granted exist because of this pattern. It’s…
Factory Pattern Explained Simply
Creational patterns abstract the instantiation process, because sometimes using new is just not cool enough. This is because instantiation can often times lead to coupling problems. Coupling problems are not cool. When you see “new”, think “concrete”. – Head First Java While this is a play on words, it is…
Clean Code 101: Error Handling
Error handling is a balancing act. Too much and unnecessary errors will drive you insane. Too little and you have a terrible user experience. When things go wrong we are responsible for making sure that our code works. Use Exceptions Rather Than Return Codes Exceptions are new in the world…
Clean Code 101: Functions
Computers can do 2 things: store data and do things with data. Functions are what we do and describe actions we take with the data we already have (or want to create). Consider this code: Can you figure out what this function is trying to do? Probably not. This is…