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.
Dr. Venkat Subramaniam is an award-winning author, founder of Agile Developer, Inc., creator of agilelearner.com, 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 agiledeveloper.com. You can reach him by email at email@example.com or on twitter at @venkat_s.