
Explore Scala, scalable language that blends object oriented and functional programming on the Java platform. See how traits, function values as objects, and Java interoperability enable building scripts to systems.
Discover the basics of Scala variables, using val and var with type inference, print hello world, and grasp reassignment rules and multi-line input via the Scala interpreter.
Learn to write Scala functions with def, parameter and result types, use if expressions, explore unit, and run scripts with println, args, and comments, including simple string concatenation.
Explore while loops and if conditions in Scala, demonstrate printing and incrementing, discuss type inference and braces, and compare imperative and functional styles with for expressions.
Learn to parameterize Scala arrays with types and values, using type parameters in square brackets and value parameters in parentheses, with practical array initialization.
Explore how Scala arrays are parameterized by types, accessed with apply, updated with update, and created via the apply factory for concise initialization.
Learn how Scala lists enable functional programming with immutable lists built from cons and nil, support for prepending elements efficiently, and strategies to append via reverse or a list buffer.
Learn how Scala tuples are immutable containers that hold mixed types, access elements with underscore indices, and return multiple values compared to lists.
Explore mutable and immutable sets in Scala, import scala.collection.mutable.set, create a mutable movie set, add elements with +=, and work with maps and hash sets.
Explore how Scala balances immutable values (vals) with mutable vars, refactoring imperative code into a functional style, minimizing side effects and embracing unit results for testable programs.
Explore writing a scala script that reads lines from a file and prints each line with its length, using a functional style and optional formatting to align the output.
Explore Scala programming concepts like classes and objects, including fields, methods, and private state, using a checksum accumulator example to show instantiation, mutability, and access control in a Scala application.
Explore how Scala handles class design with a checksum accumulator, define side-effect methods, and use semicolon inference to write concise, unit-typed procedures.
Explore singleton objects in Scala by contrasting them with classes, and learn how a companion object shares private members with its class, exposes a calculate method, and uses a cache.
Define a standalone singleton object with a main method as the entry point, import the checksum accumulator, and print each argument and its checksum separated by a colon in Scala.
Explore scala's basic types, including byte, short, int, long, char, and boolean, alongside strings, floats, and doubles, and learn their Java-like ranges, literals, and operator behavior.
Discover how Scala represents literals, from floating point, floats and doubles, to character literals with octal, hex, and unicode escapes, plus raw strings and stripMargin for multiline text.
Explore symbol literals in Scala, including their interned nature and how to pass names, and learn that operators are just methods with infix, prefix, and postfix notation.
Explore Scala arithmetic with infix operators for addition, subtraction, multiplication, division, and remainder across types, including unary plus/minus and integer vs float behavior, plus relational and logical operations, including short-circuiting.
Learn bitwise operations in scala, including and, or, xor, and unary complement for integers, plus left, right, and unsigned shifts. Understand object equality with equals and null comparisons.
Scala explains reference equality with EQ and NE, and details operator precedence and associativity, including assignment operators and how the first and last characters of operator names affect evaluation.
Explore designing immutable functional objects in Scala by building a rational class with numerator and denominator, supporting addition, subtraction, multiplication, and division, using primary constructor.
Enforce non-zero denominator for rational numbers using preconditions in the primary constructor. Create an immutable rational with a safe add method returning a new rational.
Explore working with rational numbers in Scala, accessing numerator and denominator, and implementing comparison and max methods using this reference, while reviewing constructors and auxiliary constructors.
Explore auxiliary constructors in Scala by modeling rationals with a single-argument constructor that defaults the denominator to one, invoking the primary constructor.
Learn private fields and methods in Scala by building a rational class that normalizes numerator and denominator with a private gcd and abs, and overrides toString.
Learn to define operators in Scala by implementing a rational class with plus and multiply methods, supporting x plus y syntax and operator precedence for rationals.
Explore Scala's identifier rules, including alphanumeric, operator forms, and constants, and how camel case, underscores, and the dollar prefix affect variables, methods, and classes, plus how the compiler mangles operators.
Explore method overloading in Scala to support mixed arithmetic on rational numbers and integers, with overloaded plus, minus, times, and divide methods and compiler driven resolution.
Explore method overloading in Scala by building a rational class with plus, minus, multiply, divide, and gcd-based normalization, plus custom constructors and implicit conversions.
Explore Scala's built-in control structures—if, while, for, try, match, and function calls—and how they produce values, with libraries providing most controls and immutable vals.
Explore Scala while and do-while loops, understand unit values, and compare imperative and functional styles while looping until conditions meet, with gcd and input examples.
Explore how Scala's for expressions act as a versatile tool to iterate over collections, filter with if, and yield new collections, illustrated by range examples and a directory listing.
Explore advanced Scala for expressions by adding file filters, implementing nested loops, and yielding results; learn syntax with semicolons or curly braces and binding intermediate values.
Explore Scala exception handling with try expressions, throwing and catching exceptions, understanding throw as an expression, and using catch clauses with pattern matching to handle errors.
Master Scala's try-catch-finally to handle exceptions and yield values. Learn the resource management idiom—acquire, try, then close in finally—without changing main results, noting Scala's no-checked-exception requirement.
Master Scala match expressions to select among alternatives with arbitrary patterns, no fall through, and optional value yield, illustrated by salt to pepper and chips to salsa.
Translate Java loop patterns to Scala by rewriting the while loop with an if guard or a recursive function, using argument length checks and starts with and ends with checks.
Learn how Scala manages variable scope, including nested scopes and inner definitions, unlike Java, with curly braces and val/var, and how redefining in the same scope is not allowed.
Explore variable scope in Scala, including shadowing of inner variables, contrasted with Java, and refactor imperative code into a functional, side-effect free multi-table generator using for and vals.
Explore Scala methods and various function forms, including nested functions, function literals, and function values, and learn private and local function patterns to manage code with first-class functions.
Explore first-class functions in Scala, writing function literals and values, and invoking them with apply. Learn short-form literals, target typing, and using for each and filter on collections.
Explore how to write concise function literals in Scala using underscores as parameter placeholders, and learn about partially applied functions and type annotations to control parameter inference.
Discover how Scala creates function values from sums with underscores, preview the compiler-generated apply method, and master partially applied functions and for each usage.
Explore how Scala implements first-class functions by capturing free variables in closures, producing runtime function values that reflect external changes and maintain per-closure bindings.
Explore Scala repeated parameters and varargs using a star for the last parameter and colon underscore star to pass array elements to echo. Tail recursion runs without overhead.
Explore tail recursion in Scala, learn how tail calls optimize stack usage, and understand limitations with indirect recursion, function values, and repeated parameters.
Explore reducing code duplication through higher-order functions and function values, learning currying and binding parameters to build control abstractions for flexible file search API.
Explore how first-class functions and closures reduce code duplication in Scala programming by implementing flexible file matching with ends with, contains, and regex, and using placeholders.
Explore how higher order functions reduce code duplication and power client application programming interfaces in Scala, using exist for search, and master currying and placeholder notation.
Explore creating new control structures with first-class functions, implement patterns like the loan pattern with resources, and use curly braces and currying to craft cleaner control abstractions.
Explain by-name and binding parameters in Scala, illustrate with my assert vs boolean assert, and show how by-name parameters enable concise, side-effect-free control patterns using higher-order functions.
Examine a two dimensional layout library using composition and inheritance to build rectangular text elements with abstract classes, combinators like above and beside, and factory methods.
Explore parameter list methods in Scala, distinguish parameterless from empty-parameter forms, and apply the uniform access principle. Define height and width in an abstract element using contents length.
Extend Scala classes by creating a subclass that implements the abstract contents method, inherits from element, and explores composition and the uniform access principle with val or var fields.
Learn invoking superclass constructors in Scala to define new element forms, such as line and uniform elements, and explore how overriding and polymorphism affect safe, evolvable design.
Explore how Scala handles inheritance and dynamic binding by overriding a demo method in array and line element classes while uniform element inherits the superclass implementation, showing runtime method resolution.
Discover how to declare final members and final classes in Scala inheritance to prevent overrides, fragile base class issues. Compare inheritance with composition and explore above, beside, and mkString formatting.
Explore how to define a factory object in Scala to centralize object creation for layout elements, using a companion object with overloaded LM methods to hide implementation details.
Explore scala's class hierarchy from any to nothing, including null, with anyval and anyref, and learn how value classes derive from them and use implicit widening.
Discover how Scala implements primitives, stores 32-bit integers, and uses autoboxing for Java interop, and how equality handles value versus reference semantics and bottom types like Null and Nothing.
Explore a Scala case study on employee data analysis, using biometric in and out hours to determine hikes, and design file and database schemas with JDBC.
Install scala, mysql, mysql workbench, and the IntelliJ IDE, verify scala installation and version compatibility, and follow platform-specific steps for Windows, Linux, or macOS.
Install MySQL and set up MySQL Workbench as the UI to connect to a local MySQL instance, start the server, and run queries, then download IntelliJ IDEA for development.
Create a Maven-based Scala project in IntelliJ, configure the Scala SDK and libraries, mark sources root, and organize code into packages for configurator, database operations, and file reader utility.
Walk through a CSV-based employee dataset, detail the columns and in-time/out-time entries, discuss monthly ratings, and show setting up a database connection with a config reader and JDBC URL.
Configure the pom.xml by introducing a properties tag to manage library versions and add a type-safe library for config properties, then resolve the red highlighted area and build the project.
Define and manage project dependencies using a properties section and global version variables in a dot XML file, enabling automatic jar loading for the config reader and DB operations.
Learn how to use jdbc api to load properties, load the driver, establish a connection, read data with a statement, and prepare insert with parameters.
This lecture implements a Scala csv reader utility that reads csv files using buffered source, splits lines by comma, drops header, maps to variables, and inserts records with database methods.
Read the employee file from the classpath via getResource and getPath, then feed it to the CSV reader and load data into MySQL 8.0.21 using the Java driver.
Insert and fetch data from a MySQL database using an invoker to read csv files from the resources folder, validate formats, and verify records for xyz and abc.
Course Introduction
Welcome to "Scala Programming - From Basics to Advanced," a comprehensive course designed to take you from a beginner to a proficient Scala developer. Scala, known for its concise syntax and functional programming features, is a powerful language that runs on the Java Virtual Machine (JVM). This course is tailored to provide a deep understanding of Scala, making it an excellent choice for both new and experienced programmers looking to expand their skills.
Section 1: Scala Programming
In this section, students will gain a thorough grounding in Scala programming. We begin with an introduction to the language, where students will learn about Scala's syntax, variables, and the basics of writing scripts. As we progress, we'll delve into loops, conditions, and parameterizing arrays with types, providing a solid foundation in control structures and data manipulation.
We'll cover essential topics such as lists, tuples, sets, and the differences between mutable (vars) and immutable (vals) data structures. Students will also learn how to create sets in tuples through scripting. The section continues with an in-depth look at classes, fields, methods, and semicolon inference, as well as singleton objects and app development in Scala.
Advanced topics include basic types, character literals, operators, arithmetic, and bitwise operations. We'll explore rational objects, preconditions, auxiliary constructors, private fields, methods, operator definitions, and method overloading. Control structures like if expressions, while and do-while loops, for expressions, and exception handling with try expressions will be thoroughly covered. The section concludes with match expressions, variable scope, first-class functions, repeated parameters, reducing code duplication, higher-order functions, new control structures, and by-name parameters.
Section 2: Project On Scala: Employee Data Analysis
This project-based section is designed to apply the skills learned in Section 1 through a real-world scenario: Employee Data Analysis. Starting with an introduction to the project, students will set up their development environment, create project structures, and configure necessary dependencies.
The project will involve reading and manipulating CSV data using Scala, leveraging JDBC API for data insertion and fetching, and working with files from the classpath. Students will gain hands-on experience in configuring POM, understanding data structures, and executing Scala-based data analysis tasks.
Course Conclusion
By the end of this course, students will have developed a robust understanding of Scala programming, from basic concepts to advanced techniques. They will be well-equipped to handle real-world programming challenges, particularly in data analysis and application development. This course will empower students to harness the full potential of Scala, making them proficient in one of the most versatile programming languages in the industry.