How to Fail at Almost Everything and Still Win Big?

About the book

This is the book written by Scott Adams, creator of a famous comic strip Dilbert. Scott Adams had failed at many things, but still achieved great success. In this book, Scott tells the semi-entertaining tale of how did he go from a series of failures to a successful cartoonist. He shares many good strategies that we can apply in our life to be healthy , happy and successful.

Key Messages of the book

Continue reading...

How can you create flexible enums with different behaviors and associated values?

Enums are great to group objects with similar behavior. They are also efficient because only one instance of them will get created. However, it’s hard to implement enums for classes that has slightly different behaviors. Let me illustrate with an example.

Example: Stats Calculator

Let’s say we want write a Stats Calculator to compute mathematical statistics for list of values for eg. SUM, COUNT, AVG, QUANTILES . Let’s first define an interface.

Continue reading...

How will you handle null references if you are designing a new language?

Computer scientist Tony Hoare Said:

I call it my billion-dollar mistake. It was the invention of the null reference in 1965

The nullable objects introduces a fundamental problem with type system. For e.g If you declare a object as String, it doesn’t guarantee that the value is real String or null.

We normally skip null checks based on our assumptions in control flow of code. But when we are wrong, the code crashes with Null Pointer Exception. Java 8 introduced Optionals to deal with Nullable objects. But it has some flaws

Why Java Optionals is not a great way to handle nulls?

Continue reading...

Java is too old, What should you learn in 2018?

Java has become legacy. It can’t evolve in to a modern language while keeping its backward compatibility. But it has given us a wonderful JVM ecosystem and lead to creation of many good languages Groovy, Scala, Clojure, Kotlin.

Welcome the newest baby Kotlin

Kotlin was born in 2011, But it gained popularity last year after google announced it as official language for Android. Kotlin has brought powerful features from many other JVM languages. Let take a quick glance at benefits of Kotlin for a Java developer.

Never worry about NPEs

Continue reading...

How can you Introduce Python programming to middle school students?

This is the third part of my article about teaching computer science at Community Montessori School, Tampa.

In previous article, I shared how I taught computer science algorithms. In this article, I will write about how I taught python programming to 7 to 9th grade students.

How I prepared?

Since I already taught them Search algorithms and guessing number game algorithm in previous session. I wanted to teach them just enough python programming to turn those algorithms to python code.

Continue reading...