Scala is one of the most popular functional programming languages that run on the JVM. This course takes you on a deep dive into Scala concepts such as object-oriented programming, closures, creating control structures, traits, and iImplicits.
Scala is a great choice to learn and practice both Object-Oriented and Functional programming styles, because it offers a nice blend of both paradigms. In this course, Scala Fundamentals, you'll evolve your understanding of Scala by learning about the new ideas and concepts it offers. You'll start by learning how to write object-oriented code in Scala. Next, you'll dive into the basic types that Scala provides and how you can create your own. You will then examine functions, including function literals, function values, and closures, before exploring how you can create your own Control Structures using the concept of currying. Finally, you’ll learn about Traits and how to create stackable modifications, how to use the reduce and fold concepts of Collections, and about Implicit conversion and all the use cases that the feature has to offer. By the end of this course, you’ll be able to put these techniques into practice in your own Scala applications.
Harit Himanshu is an engineer by profession with the deep interest in applying technologies to solve business problems. Harit is passionate about writing clean, modular, testable code and believes in automating almost everything.
Course Overview (Music playing) Hi everyone, my name is Harit Himanshu and I welcome you to my course, Scala Fundamentals. I am an independent software consultant with decades of experience in developing and shipping software in various domains such as CleanTech, Advertising, Web Security, and FinTech. I'm also co-founder for MoneyBonsai, an application that helps you track, manage, and analyze your finances. It is no doubt that Scala is one of the best languages on JVM platform. It definitely has a learning curve, but once you know the concepts behind them, the productivity that you get, along with the safety, is unmatchable. I love working with the functional programming in Scala as a language, and I'm excited to take you further in your learning journey with this course. In this course, you're going to take a deep dive into object-oriented parts of Scala. You will learn about closures, function values, currying, and creating your own control structures. You will also learn about traits and how you could leverage them in your own products by creating stackable modifications. You'll also learn and work with powerful methods available on collections, such as reduce and fold operations, and you will also cover what implicit conversions are and work through various places where implicits can help us widely concise and leaving off the redundant details. But that's not it, we will do that not only by looking at the smaller examples, but also building a project together where we will create our own bank and apply each of these concepts learned into our project. By the end of this course, you will have gained all the knowledge to start creating or contributing to Scala projects. I hope that you will join me on your journey to learn Scala with Scala Fundamentals course at Pluralsight.
Introduction Hello there. In this module, we are going to learn what you will learn and be able to apply after learning this course. We will talk about what you must know before diving into this course. Clarifying these assumptions will help you decide whether you should take this course or take the other ones before continuing with this course. This will help you assess whether this course meets your needs or not. We are going to cover the Scala installation with IntelliJ IDEA. This will help with setting the structure and the tone for the rest of the course. Then, we will show you how you can run small experiments with the code samples in IntelliJ using a feature called Worksheets. This will help us learn new concepts by writing small pieces of code before integrating them in our project. You will find this exercise immensely useful while working with Scala. My intent in this course is to help you move further in your Scala journey by taking the small steps and making something bigger as you learn new ideas. I hope that this process makes you productive and you get the value out of your time that you have chosen to invest. So, let's dive right in!
Understanding Object-oriented Scala In this module, we are going to cover the object-oriented face of Scala. Even though Scala promotes the functional style, it is important to know that Scala is a blended language, which means it supports the functional and the object-oriented sides. Learning the object-oriented style will help you to compose the biggest programs and projects, once you know how it works under the hood. Things that we will cover in this module are understanding what classes are and what objects mean, how to create the classes in Scala and how to create objects from them. Here we will also look at various access modifiers that can be applied on the class members to exhibit different behaviors when it comes to expose the data. Then, we will find out what companion objects are and in general what singleton objects are; when and how to use them. Then, we will evolve our learning to improve class design pattern and see why we should use functional objects and what benefit they bring to us. Then we will dive into more sophisticated object-oriented patterns, such as abstract classes, inheritance, and composition, and learn how to represent them in Scala. Once we are finished covering the concepts and examples, we will dive into building our project. We will develop the initial classes, some behaviors, and create a relationship between these classes. This is where all of the learning will come into practice. Keep in mind, though, that the application will be in its early stages and we will work on more modules as we go and refactor the parts of application to use Scala to its full potential. As programmers, this is how our work goes as well, right? We learn a new pattern or concept that can make our code better, safe, shorter, and maintainable. So, are you excited for this ride? Let's do it then!
Working with Basic Types In this module, we are going to learn about the fundamental Scala types and see their examples. Then we will learn about how we can embed Scala expressions in the string literals. We will learn about different types of interpolators here. Then we will cover operators and see that the operators on types are nothing but methods. We will see how operators are classified and how they are represented in this module. Then we will move our attention to understand the Scala class hierarchy. It is very important to understand this hierarchy, since everything that we write in Scala is based on the understanding on how classes provided by Scala are organized. We will then take this knowledge and refactor our project to make it better by using what we have learned. So, let's continue with our next step.
Working with Functions and Closures In this module, we will talk only about functions. Things that we will do here would be understanding the local functions, understanding what function literals and function values are and how they are related, understanding what partial applied functions are, understanding what closures are and how they are related to the partially applied function. We will see a pattern which provides convenience over passing arguments of same type repeatedly. We will also see how Scala provides a way to apply default value when declaring function parameters, and how you can name the parameters when calling them to have any order of arguments being passed. We will also explore the concept of tail recursion and how it is implemented in Scala. And then we will take this learning to refactor our project even further. Let's get in right away to learn and apply this new required knowledge.
Creating Your Own Control Structures All right, so in this module, we will learn how to leverage function values to remove code duplications. We will understand what currying is and how to create curried functions. Then, we will create our first control abstraction. We will leverage currying here to make it possible. Then, we will learn about by-name parameters and see why they are important. And finally, we will make changes to our code base to leverage what we have learned in this module. Let's get started.
Working with Traits All right, so in this module, we will first understand what traits are and how to use them. Then we will dive into looking at our first popular use case of traits where we create the rich interfaces based on the existing shallow interfaces. Then we will dive into the second popular use case where traits are used to create the stackable modifications. We will also quickly dive into recommendation on when to use or not use traits. And finally, we will refactor our project to make use of traits. So, let's dive in and start the learning.
Understanding Collections This is going to be a relatively smaller module. If you're looking for how to use many of the collections and the collection hierarchy, I would strongly encourage you to watch collection modules mentioned in the course prerequisites. The concepts in this module will give you power to work with two of the most important collections methods. We are first going to look at how to reduce works for a given collection, and then we will look at how fold works and how its variants work. And then we will put these methods to use in our project. So without any further ado, let's start learning!
Working with Implicits In this module, we will learn about implicits. This is a very important topic in Scala. When reading the code for others, sometimes we see obscure code and are not able to find out how something that is not supposed to work is working. Implicits under the hood does the heavy lifting for us to make things happen. We will cover what implicit conversions are, how they work, and we will cover truth and working example to demonstrate that. Then, we will cover the rules that we must learn when writing implicits in our own code. This will help us make better design choices and guide us in the case when the code doesn't work as expected. Then, we will see where implicits are tried in Scala. This is where we will cover various places where implicits exist and see the code examples for each one of them. And finally, we will evolve our project by taking this learning into action. So, let's get started.