Programming with Scala Traits – Part One

NFJS, the Magazine - August 2011

In object modeling, mixins provide a way to create abstractions that define a common functionality that can be mixed into different abstractions. As Java programmers we did not quite have the ability to make use of this powerful concept, especially because Java does not provide multiple inheritance. In languages that do provide multiple inheritance, like C++, this is quite difficult to use in practice due to problems with method collision. Scala elegantly supports compile time mixins through traits. In this first part of the series, we'll learn about traits in Scala and how to use them. In the second part, we'll learn how to apply multiple traits both at class and instance levels.

An online version of this article is not available. This article is available in PDF, MOBI, and EPUB to those who have subscribed.

About Venkat Subramaniam

Venkat Subramaniam

Founder of Agile Developer, Inc.

Dr. Venkat Subramaniam is an award-winning author, founder of Agile Developer, Inc., creator of, and an instructional professor at the University of Houston.

He has trained and mentored thousands of software developers in the US, Canada, Europe, and Asia, and is a regularly-invited speaker at several international conferences. Venkat helps his clients effectively apply and succeed with sustainable agile practices on their software projects.

Venkat is a (co)author of multiple technical books, including the 2007 Jolt Productivity award winning book Practices of an Agile Developer. You can find a list of his books at You can reach him by email at or on twitter at @venkat_s.

NFJS, the Magazine - August 2011

NFJS the Magazine - August 2011

In this Issue: