Link to slides: http://talks.samirtalwar.com/use-your...
Use your type system; write less code
Building a large application often feels like an exercise in futility. No matter how we do it, even test-driving everything, there’s always one more bug. We make one thing more robust and another falls over. Anything that can go wrong will go wrong. And when that massive change request comes in, building a new feature while keeping the bugs out is even harder.
So what if things couldn’t go wrong?
I want to talk to you about types.
You’re probably familiar with classes and at least one variant of object-oriented programming. You know what types are and you use them all the time. So what are you missing?
First of all, I want to talk about readability. Often, we use classes for enhancing the behaviour of values. Let’s do the opposite: reduce the behaviour. It's the Unix philosophy. 'Do one thing, and do it well.'
Secondly, I’d like to look at flexibility, and how to write code that really is changeable without spending weeks and introducing regressions. We’ll look at polymorphism, composition, and a few refactoring techniques.
Thirdly, let’s wander into the scary-sounding halls of correctness. We’ll look at our type system not as an encapsulation mechanism but as a theorem prover, using it to iron out potential bugs before they can take root.
Finally, we’ll venture into the halls of optimisation, using our new types to improve performance without damaging the quality of our code. We’re going for maintainable code that’s fast too.
Programming languages have come along leaps and bounds in the last 20 years, but often we code as if we’re still writing in that original dream of Bjarne Stroustrup, 'C with Classes'. We can do so much better.
(Recorded at the Liberty Stadium, Swansea - SwanseaCon 2015)
www.swanseacon.co.uk