DevCon³: Scala Best Practices

Tomer Gabel
Tomer GabelConsulting Engineer at Substrate Software Services
Scala Best Practices

Tomer Gabel @ DevCon³
    February 2013
• Scala is awesome

• But it’s new

• … and
We’re gonna focus on…   DO’S AND DON’TS
… overuse tuples
DevCon³: Scala Best Practices
… did you know you can do this?
… use null
… use Option!
… overload operators
What the hell does this mean?

 s(7) <*> (s(8) <*> (s(9) ∘ add3))
… abuse implicit parameters
def lookup( id: Int )( implicit jdbcUrl: String )

  • Danger, Will Robinson!

  • Primitives may be reused elsewhere

  • Wrong semantics
… abuse implicit methods, either
implicit def stringToInt( x: String ) =

 Implicit conversion considered harmful
   • Performance
   • Ambiguity
   • Code locality
… over-import
import package1._
import package2._
import package3._

   • Namespace pollution
   • Slow compilation
   • Unintended implicits
… study the collection framework
• It’s a layer cake!

• Always qualify mutability
  – Aim for immutability
  – But have no fear

• Many gems!
… abuse the type system
• Path-dependent types

• Visibility modifiers (e.g. package-

• Case class inheritance
  – Not allowed in 2.10
Our time is
almost up!

Thank you for

Get in touch:
• @tomerg
1 of 27

More Related Content

Similar to DevCon³: Scala Best Practices(20)

Scala in the WildScala in the Wild
Scala in the Wild
Tomer Gabel2.8K views
Can you TDD Rails?Can you TDD Rails?
Can you TDD Rails?
Andrzej Krzywda2.8K views
Clean code, Feb 2012Clean code, Feb 2012
Clean code, Feb 2012
cobyst1.3K views
Beginning Java for .NET developersBeginning Java for .NET developers
Beginning Java for .NET developers
Andrei Rinea18.4K views
Writing clean code with Java 9+Writing clean code with Java 9+
Writing clean code with Java 9+
Miro Cupak1.3K views
Moving from C++ to RubyMoving from C++ to Ruby
Moving from C++ to Ruby
Leslie Brown3.2K views
Ruby for C#-ers (ScanDevConf 2010)Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)
Thomas Lundström888 views
Writing Readable CodeWriting Readable Code
Writing Readable Code
eddiehaber1.7K views
Ruby Presentation - ArticleRuby Presentation - Article
Ruby Presentation - Article
Christopher Giroir263 views
Lua pitfallsLua pitfalls
Lua pitfalls
Dmitriy Kotelnikov613 views
Rails trapsRails traps
Rails traps
Reuven Lerner4.4K views
Alex Scotti3.1K views

More from Tomer Gabel(20)

DevCon³: Scala Best Practices

Editor's Notes

  1. Image source:
  2. Image source: (no license specified)
  3. Image sources: (public domain) (public domain)
  4. Sample code taken from thescalaz Applicative example:
  5. Image source: (license unknown)Such “gems”: IterableLike.sliding, TraversableLike.groupBy, a Map is also a function!