Latest published articles

Java Tip: Method Reference

Java Tip: Method Reference

Instead of

for(String name: names) {
	System.out.println(name);
}

Do

// This is called a method reference
names.foreach(System.out::println);

Rules of Thumb for Software Developers

Rules of Thumb for Software Developers

Fetching Data

  • Remember Performance issues go unnoticed during development because the data set is too small - Vlad Mihalcea
  • A transaction should fetch only as much data as required by the current executing business logic - Vlad Mihalcea

Optimization

  • Premature optimization is the root of all evil - Donald E. Knuth
  • Measure performance before and after each attempted optimization. J Bloch
  • Programs spend 90 percent of their time in 10 percent of the code.

Design

  • The components of design that are most difficult to change after the fact are those specifying interactions between components and with the outside world. Cheif among these design components are APIs, wire-level protocols, and persistent data formats. Bloch
  • Strive to write good programs rather than fast ones. J Block

Install Heroku CLI and Setup  Heroku Autocomplete

Install Heroku CLI and Setup Heroku Autocomplete

On a Mac command line

brew tap heroku/brew && brew install heroku

Enable heroku autocomplete

heroku autocomplete
printf "$(heroku autocomplete:script bash)" >> ~/.bashrc; source ~/.bashrc

To use autocomplete type: Heroku and Tab,Tab

Java Tip: ComputeIfAbsent

Java Tip: ComputeIfAbsent

Often we have to loop through a list of items and convert it into a map, with the key being some sort of category and the value being a set of the associated items ie Map<Key, Set<Object>>. The old way of doing this looped through the list and before adding checked if the key was present. Using computeIfAbsent we can clean up this syntax considerably.