27 Apr 2018. 0 min read.
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...
18 Apr 2018. 1 min read.
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...
09 Apr 2018. 1 min read.
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...
03 Apr 2018. 1 min read.
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...
02 Apr 2018. 0 min read.
This is second part of my article about teaching computer science at Community Montessori School, Tampa. In previous article , I shared what I taught about computer science and software engineering job. In this article, I will write about how I taught computer science algorithms to 7 to 9th grade students.
How I prepared?
I introduced flowcharts to them so that they could learn to represent algorithms.
Continue reading...