Scala on Discord

Some thoughts[1] on Alex Nedelcu’s post about the Scala community moving from Gitter to Discord. While Discord may not be the best choice, Gitter doesn’t cut it. It is primitive, lacking, and plain absurd. Unless you are on Gitter 24/7, it is hardly usable[2] as…

Defining sum types across files

Despite all the power and utility that `case class`es provide, there are a couple of things that Scala could have done better. This post discusses the situation of defining the (ADT) sum type companions across multiple files.…

Anorm Primer

A primer on Anorm highlighting interesting parts - core and combinator functions, and situations when you don't have a predefined type for the parsed row, and you are dealing with discrete columns in the result set based on time and need.…

Know Thy Option

Avoid `.get` at all costs. Forget there is even an `Option.get`. There is always a way out - better one. Same applies to `.head`. Likewise, consider extending your test classes from `OptionValues`.…

Patterns for Saner Mocking

It is common to see mocks being setup this way in unit tests. scenario("Test Case 1") { ... when(addressResolutionService.resolve(...)).thenReturn(...) when(vendorInventoryService.checkInventory(...)).thenReturn(...) ... .... another bunch of when and then returns when(shipmentService.schedule(...)).thenReturn(...) ...thisIsTheActualCalltoTest(...) verify(vendorInventoryService, 1).checkInventory(...) ... other such verifications } scenario("Test Case…

Non-FP to FP Conversion Caveat

Sometimes you learn the best from others; by watching. This post is based on such an instance. A fellow engineer on my team was investigating a nagging issue - partially-successful operations or rather operations that left data in an inconsistent state. It goes without saying that I take no credit…