Archives for Jed Wesley-Smith

Scala: Types of a higher kind

One of the more powerful features Scala has is the ability to generically abstract across things that take type parameters. This feature is known as Higher Kinded Types (HKT). This feature allows us to write a library that works with a much wider array of classes, whereas without the feature you are condemned to bespoke and error ridden code duplication for each class that may want the functionality. Type constructors Essentially what HKT gives us is the ability to generalize across type

Continue reading »

One of the greatest things about our software development process is our need and desire to test everything. Unfortunately, this doesn't always translate into absolute best practices in the test code, coverage, or design, but we are always improving. Something I have been been meaning to get around to is property based (or automated specification based) testing. The traditional approach to unit testing (and TDD) is to write a test, see red, and then go fix it. If doing TDD religiously, this can

Continue reading »

Scala and Erasure

Mention generics to anyone who knows much about them and they'll usually have an opinion on type reification and erasure. For the uninitiated, erasure is where a List of Strings (or a List parameterised by the String type) "forgets" that it has been parameterised by the String type once it has been compiled – ie. the type parameter is erased. Reification is the opposite, the type is remembered, or reified. Different platforms have different strategies for their generics implementations.

Continue reading »

Exceptions are Bad™

**Exceptions should be used for exceptional circumstances!** Exceptions are to be used when bad shit happens. Not because you got passed some bad data (as in not passing validation), but because someone pulled the plug on your disk drive, or an earthquake hit your data-centre. They're for bad shit alright?

Continue reading »