Question: I am learning Scala and Akka and in my recent lookup for a [solution](https://stackoverflow.com/questions/22770927/waiting-for-multiple-results-in-akka), I found something like 

```
 case class TotalTaxResult(taxAmount:Double)
 case object TaxCalculationTimeout

```

What is the difference between the two?

When should I use one over the other?

Answer: 
A case object is a singleton case class. They are used kind of like enumeration values. It can be used in pattern matching just like any other value:

```
TaxCalculationTimeout match {
  case TaxCalculationTimeout => println("hello")
}

```

When you define a case class, you are creating a template for instances of that class. `TotalTaxResult(1.0)` and `TotalTaxResult(2.0)` are two different values of the same type. Whereas there is exactly one `TaxCalculationTimeout` value.
In simple words, Scala is a Object Oriented and Functional programming language. It have features of functional programming like pattern matching with pure object oriented methodology. 

Some times, we need to create singleton object without any value like passing some signal for pattern matching. If scala have not concept of case object we just to need to use enum or equals some string value in matching. But this is not a readability in pure Object Oriented language.. In that scenario we are using Case Object

Case classes are used when we need to create multiple objects with different values.