Chapter 5: A Beginner's Tutorial To Using Traits In Scala

By Nadim Bahadoor | Last updated: July 25, 2017 at 14:32 pm

In this section, we will go over how to define and use traits in the Scala programming language.

 

If you recall from the Scala Introduction tutorial, Scala is both an Object Oriented and Functional programming language.

 

The examples in this chapter will start off with using traits in an Object Oriented fashion. As we progress throughout the chapter, we will show how to leverage traits in a pure Functional context.

 

Throughout the tutorials we will use the popular IntelliJ IDEA which we've setup in Chapter 1. I hope that by now you are more comfortable using IntelliJ. If not, feel free to review the previous tutorials from Chapter 1!

 

In this chapter, we will provide tutorials on the topics below. If none of these make any sense right now, that's OK :)

  • Extend a single trait
  • Extend multiple traits
  • Using traits for dependency injection
  • Dependency injection and the infamous Cake Pattern
  • Mixin traits
  • Traits as foundation to Functional Programming

So let's get started!

Nadim Bahadoor on FacebookNadim Bahadoor on GithubNadim Bahadoor on LinkedinNadim Bahadoor on Twitter
Nadim Bahadoor
Senior Software Developer | Elsevier
Founder of allaboutscala.com. I have over 10 years of experience in building large scale real-time trading systems in the financial industry. Passionate about Distributed Systems, Scala, Big Data and Functional Programming. Stay in touch for upcoming tutorials!

Share this article on