Skip to main content

Posts

Resonating Quote of the Day

Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live. -unknown
Recent posts

Resonating Quote of the Day

Good code is its own best documentation. As you’re about to add a comment, ask yourself, ‘How can I improve the code so that this comment isn’t needed?’ Improve the code and then document it to make it even clearer. -Steve McConnell

Helpful Reference: Iterating Through A Map

This is probably one of the most useful references I use, that I can never remember. I bookmark my references and keep going back. I'm putting it here just in case the other one disappears. An example of a java HashMap is as follows: Map<Integer, String> myMap = new HashMap<>(); It can contain only objects (no primitives), and you can iterate through the keys, the values, or both. Iterating through the keys: for(Integer key : myMap.keySet()) {     ... } Iterating through the values: for(String value : myMap.values()) {     ... } Iterating through both the keys and the values: for(Map.Entry<Integer, String> entry : myMap.entrySet()) {     Integer keyVal = entry.getKey();     String val = entry.getValue();      ... }

On Working On A Passion through Sourdough - It's All In The Details

"Working hard at something you don't believe in is called stress. Working hard at something you do believe in is called passion" - Simon Sinek Java programming is one of my passions, and has been for the last 15+ years. I have a few other passions - like gardening, baking, crocheting, and knitting - but Java has been a solid feature in my life, one way or another. In April of this year, as a pandemic started to rear its ugly head, I was offered an opportunity to grow another passion - a sourdough starter. My past credentials for bread-making have been dabbling in yeast breads, with the active dry variety, and quick breads; I have never worked with wild yeast. I realized an ember of passion was lit in me at the very beginning when I spent hours researching about sourdough starters the day before I was going to pick it up - what is it? how do I keep it alive? how do I make bread out of it? Will it attack me at night? By the time I had the starter in my hands, I had a recipe

Helpful Reference: Try-with-Resources

Try-with-resources is a wonderful addition to the java language back in version 7. It allows you to let java handle closing resources quietly after the try-statement ends, regardless of whether it's statements ended successfully or not. If you're not using this, you're probably adding at least 2 more lines of code, if not more. "Resources" that this try-statement uses is any class that implements the Closeable interface. Also, try-with-resources can be used with multiple resources in the parentheses. Example using try-with-resources try-with-resources with one resource: try(CSVReader csvReader =      new CSVReader(Files.newBufferedReader(Paths.get(fileToProcess)))) {     //read from the CSV file, line by line     ... } try-with-resources with multiple resources: try(BufferedReader bReader = Files.newBufferedReader(Paths.get(fileToProcess));     CSVReader csvReader = new CSVReader(bReader)) {     //read from the CSV file, line by line     ... } If you did a normal